My app "syncs" all the contacts on a phone with the server. However, part of the requirement is that if any contact is inserted, updated, or deleted then the sync must happen again to maintain data integrity. I know about registering a ContentObserver
on ContactsContract.Contacts.CONTENT_URI
, but any such observer would have to be unregistered on the Activity's onPause()
, and thus would not get notifications if the app wasn't running at that moment.
I also do not want to implement a content observer in a service, since services aren't permanent either. Plus, I don't like the idea of running something in the background 24x7.
So, is there any way by which I can detect that the contacts have changed since a sync? I do not need a real-time notification, so it's ok if this detection only happens when the app is run next.