开发者

How to delete only the phone number in an android phone programatically

开发者 https://www.devze.com 2023-03-26 19:58 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消