i have a Phone.Lookupkey and Phone.CONTACT_ID and i want to delet开发者_高级运维e only the phone number that it points to, i dont want to delete all the contact information.
How do i put empty value? just update it to ""?
Thanks,
simple update the phone number with empty value, fire the update query with empty string or 0 value
Sometimes only updating a phone number is not enough. After doing this you may see that you have the phone field but it is empty. I used this code:
ArrayList ops = new ArrayList(); String selectPhone = Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'" + " AND " + Phone.TYPE + "=? AND " + Phone.NUMBER + "=?"; String[] phoneArgs = new String[] { String.valueOf(rawContactId), String.valueOf(type), number }; ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) .withSelection(selectPhone, phoneArgs) .build()); resolver.applyBatch(ContactsContract.AUTHORITY, ops);
It removes the phone number with specified type and number.
精彩评论