+"?" + ContactsContract.CALLER_IS_SYNCADAPTER+"=true"),
ContactsContract.RawContacts._ID + ">0", null);
此句未调试、验证。
以下经过验证OK
/*
* 删除某人的联系人信息
*/
private void delContact(String id) {
Cursor cursor = getActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
new String[]{Data.RAW_CONTACT_ID}, "contact_id=?",
new String[]{id}, null);
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
if(cursor.moveToFirst()){
do{
long Id = cursor.getLong(cursor.getColumnIndex(Data.RAW_CONTACT_ID));
// Log.v("s", "___________"+Id);
ops.add(ContentProviderOperation.newDelete(ContentUris.withAppendedId(RawContacts.CONTENT_URI,Id))
.build());
try {
getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
// Log.e("s", "___________"+Long.valueOf(id));
}
}while(cursor.moveToNext());
cursor.close();
}
}