Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Updated Contacts in Android for Contact Sync

I am working on Contact Sync in Android and I have successfully done with First time Contact Sync.

Here is what I am doing. 1. Fetching all Contacts and Saving each contact in DB with Contact._ID 2. Fetching Names and Phone Numbers and saving in DB.

After that I am sending my contacts data to server so that server can be updated.

Now the problem is how can i check whether my particular contact is updated or not ?

I have implemented Broadcast Receiver so that my app can get intimated about the updation/Addition/Deletion of Contact. But I want to tract particular contact.

I found one solution which is Dirty Flag. It tells us about the contact whether its updated or not, Here is the reference link : http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html

But I am not able to use this Dirty Flag, Could someone please help me by implementing Dirty Flag.

Thanks in Advance !

like image 705
Gaurav Singla Avatar asked Apr 23 '15 06:04

Gaurav Singla


People also ask

How can I see my Google synced contacts?

You can use http://contacts.google.com to access all the same information from any device with the same Google account added onto it.


Video Answer


2 Answers

The contacts should have the value ContactsContract.RawContacts.VERSION.

If you save this version on the server (or in a database in your app), you can determine if a contact has changed since it was last sent to the server.

like image 129
tknell Avatar answered Sep 21 '22 21:09

tknell


You will get number of contacts updated after a particular time from contact data base using below query.

 ContactsContract.Contacts.CONTACT_LAST_UPDATED_TIMESTAMP 

,try to compare the last uploaded time to your server with this time .Hope then you will get the list of updated contacts after the successful upload to server.

check this http://developer.android.com/reference/android/provider/ContactsContract.ContactsColumns.html#CONTACT_LAST_UPDATED_TIMESTAMP

like image 39
Jithu P.S Avatar answered Sep 22 '22 21:09

Jithu P.S