I am developing an Android app which needs to know when a contact is added/updated/deleted.
So I read several posts for it. I understand that we can get notified through
Let me explain as much as I could. Basically your policy looks pretty good, but actually it is bit more complex than you thought.
On Android, a contact can be associated with several raw contacts, which may be provided from many data providers, such as Google, Facebook, Skype and so on. For example, if one of your friends in your local contacts is also using Skype, there are two raw contacts existing separately in ContactContracts.RawContacts, but they will be aggregated automatically and show up just as one contact when you query to ContactsContract.Contacts.
That is also why it's hard to identify a contact uniquely, because you can split or join them anytime you want. LOOKUP_KEY
isn't very handy for this case.
Many apps except Google only provide a one-way sync, i.e. only from service to contacts, so they are read-only. In this case, the deleted flag will not be used and simply deleted during their synchronization process. Thus, you can not simply rely on the flag.
Though there isn't a good simple solution, I guess it's much easier to achieve what you want, if you observe for a specific RawContacts
, not Contacts
. Hope this helps your understanding.