似乎可以完成工作的删除所有联系人方法是:
ContentResolver contentResolver = myActivity.getContentResolver();
Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while (cursor.moveToNext()) {
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
contentResolver.delete(uri, null, null);
}
有没有办法调整它以删除 RawContacts 而不是联系人?像这样的东西:
ContentResolver contentResolver = myActivity.getContentResolver();
Cursor cursor = contentResolver.query(ContactsContract.RawContacts.CONTENT_URI, null, null, null, null);
while (cursor.moveToNext()) {
contentResolver.delete(ContactsContract.RawContacts.CONTENT_URI, null, null);
}
我正在寻找其他方法来删除所有联系人。清除所有联系人表(联系人、原始联系人、数据)的最佳方法是什么?