Skip to content Skip to sidebar Skip to footer

Syncing Contacts Using Syncadapter ,working

I am currently working on a android project in which I want to Sync mobile contacts to server, After researching a lot about SyncAdapter and Creating account in accountmanager, I h

Solution 1:

Every modification of a contact that's done without the CALLER_IS_SYNC_ADAPTER on the Uri will make the ContentProvider set the DIRTY flag of the modified contact to 1. Similarly, every delete request without that parameter will just set the DELETED flag instead of deleting the contact.

Your SyncAdapter has to query the contacts that are flagged dirty or DELETED, take the appropriate action (send the new contact data to the server or delete the contacts from the server) and clear the dirty flag (by overriding it with 0 having the CALLER_IS_SYNCADAPTER parameter in place) or finish the removal by deleting the contact again (again having the CALLER_IS_SYNCADAPTER parameter in place).

I believe that you can not "undelete" a contact by setting DELETED to 0, since (to my experience) the contact data has already been removed at that point. Only the RawContact entry is left (though, maybe I had just a misbehaving device when I tried that the last time).

It's important to specify the CALLER_IS_SYNCADAPTER, otherwise nothing will happen (and your SyncAdapter is doomed to try to sync these contacts again and again).

Regarding question 2:

That's completely up to your SyncAdapter. You write the code to sync the contacts and you're SyncAdapter is the only one to tell if it succeeded or not. In general you probably can assume it succeeded if no Exceptions were thrown during the sync.

Post a Comment for "Syncing Contacts Using Syncadapter ,working"