On almost all devices contacts originates from some cloud-source, like Google contacts.
In which case there's a SyncAdapter
that runs periodically and goes over all contacts to make sure they're in sync with the cloud versions of them (sync up and sync down any changes).
Most SyncAdapter
s will also modify some value in the contacts data (usually SYNC1, SYNC2, SYNC3 fields of the RawContact) to store some information about the sync process,
e.g. this contacts had last been synced on that timestamp.
This makes the CONTACT_LAST_UPDATED_TIMESTAMP
field pretty useless for what you're trying to do.
If I run the query on my device, to check which contacts had been updated in the last 24 hours, I get 1003 out of 1036 had been modified.
EDIT:
If i write ContentObserver to listen for changed caontacts, will it be
called for above scenario
it will be called many many times a day, more then you expect...
the only viable option i've found is to keep a cached copy of the state of the contacts DB at a given point and to compare it with the updated state.
you don't need to keep all the data for all the contacts, just keep some hashValue (long or int) that represents a contact's state, so you need to keep a map of and persist it to a local database or a file, and after some time, you can create that map again and compare it to the previous map to figure out contacts that had been deleted, added or modified.
Make sure you only take into account interesting fields like name, emails, phones when calculating your hash-value, so those SYNC1, SYNC2 frequent changes won't trigger a false-alarm