How to delete a particular contact using contact id?

前端 未结 4 361
迷失自我
迷失自我 2020-12-17 06:39

I am trying to delete a particular contact from phone. I can delete the full contact. How to delete a particular contact using contact id. I want to delete the full datas in

4条回答
  •  不思量自难忘°
    2020-12-17 06:58

    Using Contacts.CONTENT_LOOKUP_URI is not needed if you have contactId. In fact I experimented problems deleting some contacts using it.

    The correct way if you have contactId is to directly use ContactsContract.Contacts.CONTENT_URI:

        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,contactId);
        int deleted = context.getContentResolver().delete(uri,null,null);
        return deleted>0;
    

提交回复
热议问题