Search code examples
androidandroid-contactscontactscontract

How to check which number is deleted from usercontact which has mutiple contact?


I have added multiple number under different categories for single user like,enter image description here

If I delete the one of the numbers , I want to detect which number got deleted from contact using ContactsContract content uris


Solution

  • The ContactsContract APIs can tell you that something changed in the Contacts table (via ContentObserver), but not what exactly.

    If you want to detect the change that happened you'll need to keep and maintain a cache copy of all contacts in your app, you don't need to actual data itself, just the hash of each data row for each contact.

    Then when you get your onChange called, you can go over all the data rows in the DB and compare them to the hashes you found the last time, and see if any were added/modified/deleted.