I want to get a notification on my phone if there is any change in the contact database(add,delete).Right now i am using ContentObserver to get notified.Following is my code
I have changed onChange code to this.
@Override
public void onChange (boolean selfChange)
{
this.onChange(selfChange, null);
}
@Override
public void onChange (boolean selfChange,Uri uri)
{
Cursor cursor = mCntxt.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, null, null,ContactsContract.Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + " Desc");
if (cursor.moveToNext()) {
String id = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts._ID));
String name = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Log.w("Contact ID", id);
Log.w("Person Name",name);
}
}
Hope this helps..