Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用同步适配器自动同步本地数据库_Android_Adapter_Sync_Account - Fatal编程技术网

Android 使用同步适配器自动同步本地数据库

Android 使用同步适配器自动同步本地数据库,android,adapter,sync,account,Android,Adapter,Sync,Account,我正在使用同步适配器编写一个同步应用程序,并尝试自动同步本地数据库,第一次创建帐户时,它工作正常,但当我在本地数据库中进行更改时,即使我自动设置ContentResolver.SetSyncaumatically(帐户、权限、true),它也不会自动同步。试试这个 ContentResolver.setIsSyncable(account, authority, 1); ContentResolver.setSyncAutomatically(account, authority, true);

我正在使用同步适配器编写一个同步应用程序,并尝试自动同步本地数据库,第一次创建帐户时,它工作正常,但当我在本地数据库中进行更改时,即使我自动设置ContentResolver.SetSyncaumatically(帐户、权限、true),它也不会自动同步。

试试这个

ContentResolver.setIsSyncable(account, authority, 1);
ContentResolver.setSyncAutomatically(account, authority, true);
ContentResolver.addPeriodicSync(account, authority, new Bundle(), 1);

必须在数据库中的每个事务之后调用contentResolver.notifychange(Uri、contentObserver、true)。例如,在每次插入事务调用notifychange之后,它将通知绑定到DB权限的相应同步适配器。