/** * 删除联系人 * */ public void deleteContact(Contact contact) { Log.w(TAG, "**delete start**"); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); String id = getContactID(contact.getName()); //delete contact ops.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI) .withSelection(ContactsContract.RawContacts.CONTACT_ID+"="+id, null) .build()); //delete contact information such as phone number,email ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI) .withSelection(COLUMN_CONTACT_ID + "=" + id, null) .build()); Log.d(TAG, "delete contact: " + contact.getName()); try { contentResolver.applyBatch(ContactsContract.AUTHORITY, ops); Log.d(TAG, "delete contact success"); } catch (Exception e) { Log.d(TAG, "delete contact failed"); Log.e(TAG, e.getMessage()); } Log.w(TAG, "**delete end**"); }