Synchronization happens automatically. You can add or remove contacts programmatically. But synchronization is processed by the OS automatically, if and only if the user has enabled the option "sync conatcts" in the phone settings.
However, you can start the synchronization procedure, which can trigger the synchronization process if the user can use synchronization using the following:
private void requestSync() { AccountManager am = AccountManager.get(this); Account[] accounts = am.getAccounts(); for (Account account : accounts) { int isSyncable = ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY); if (isSyncable > 0) { Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(accounts[0], ContactsContract.AUTHORITY, extras); } } }
Anup Cowkur
source share