I am working on an application whereby I need to listen to changes in native contacts database like if a contact is edited/deleted or a new contact is added.
I know I can achieve this with the help of contentobservers. However I found it pretty strange that android SDK does not provide a way to know which contact is added/deleted or which one is changed. This results in a lot of manual work like traversing through entire contact list and checking which one is changed.
I want to know if there is any better way of achieving this. I know this question would have been asked many times but I want to know why Android SDK does not have such a mechanism in place?
Aryan Kumar
02-Jul-2023There are a few ways to know if a contact is added, changed, or deleted in Android.
Here are the steps on how to use the Contacts Provider to see if a contact has been added, changed, or deleted:
Code snippet
This command will list all of the contacts on the device.
Here are the steps on how to use the ContentResolver to see if a contact has been added, changed, or deleted:
Code snippet
Replace
<CONTACT_ID>
with the ID of the contact that you want to check.Here are the steps on how to use the Contacts app to see if a contact has been added, changed, or deleted:
You can also manually check the Contacts app to see if a contact has been added, changed, or deleted by looking at the date and time that the contact was last modified.
Anonymous User
16-Nov-2015