This query returns deleted contacts some time. I have noticed if the deleted contacts belong to Gmail account and have numbers then this query will not return any result.
String WHERE_DELETED = "( " + ContactsContract.RawContacts.DELETED + "=1)";
Cursor cursor = context.getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI,
null,
WHERE_DELETED,
null,
null);
The RawContact.DELETED
marks the RawContact
for deletion, once the relevant SyncAdapter
wakes up and syncs the deletion to the server (eg Google Contacts Server) that RawContact
is actually deleted from the DB and can no longer be queried .
See official documentation :
The "deleted" flag: "0" by default, "1" if the row has been marked for deletion. When delete(Uri, String, String[]) is called on a raw contact, it is marked for deletion and removed from its aggregate contact. The sync adaptor deletes the raw contact on the server and then calls ContactResolver.delete once more, this time passing the CALLER_IS_SYNCADAPTER query parameter to finalize the data removal.
What you can do is query the ContactsContract.DeletedContacts
table which holds a record of Contacts deleted in the last 30 days, see here: https://developer.android.com/reference/android/provider/ContactsContract.DeletedContacts.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.