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.

  • Don't navigate to other pages in WebView,disable links and references
  • Set GPS Location in Emulator using Android Studio
  • how to finish all activities except the first activity?
  • Open a numeric keyboard without forcing the EditText to be numeric only
  • no resource id found for app:layout_scrollflags from CollapsingToolbarLayout
  • Android PagerView between Activities
  • 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 :

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

    Thanks in Advance !

    Related posts:

    Android 2.2 Webview causes OpenGL ES API with no current context (logged once per thread)
    converting activity into fragment
    Facebook SSO and Third Party site registration in one step?
    Get product flavor or build variant in an android app
    Implementing three actions inside a single menu item in Android
    Filter data on firebase with Searchview
  • Android Marshmallow permission model on OS 4.0 READ_EXTERNAL_STORAGE permission always not granted
  • Android Emulator Shutdown takes FOREVER
  • SSL handshake aborted Connection reset by peer while calling webservice Android
  • appcompat-v7 v21.0.0 causing crash on Samsung devices with Android v4.2.2
  • Error:Plugin with id '' not found
  • memory leak caused by initialize method of YouTubePlayer.Provider
  • 4 Solutions collect form web for “Get Updated Contacts in Android for Contact Sync”

    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.

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


    ,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

    As you said that you are storing Contacts._ID in your local database and fetching phone number and other info associated with contact from the Contacts db.

    I would suggest you to store the data from the RawContacts table into your local mapping and check the entries associated with the raw_contact_id in the data table of contacts you will get all contacts easily.

    To check the modified or deleted contacts
    With the raw_contact_id present in your local table check mapping with the data table that if contact field associated with the raw_contact_id's version is changed or isDeleted field is changed (i.e; Contact is deleted from contact application)

    When I did I used the ContactsContract.Contacts.CONTACT_LAST_UPDATED_TIMESTAMP, but I had problem to figure out that it was is milliseconds, I was using a column to get the new files and it is in seconds (MediaStore.MediaColumns.DATE_ADDED) so pay attention to use the correct number.

    Uri uri = ContactsContract.Contacts.CONTENT_URI;
    Cursor cursorNew;
    cursorNew = contentResolver.query(uri,
            ContactsContract.Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + ">=?",
            new String[]{lastUpdate},
            null        // Ordering

    ‘lastUpdate’ is a string with my timestamp

    Another thing to pay attention is this Contact’s column just appeared on API 18, the latest Jelly Bean version, so to solve this problem once and for all I just changed my gradle file.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.