user24051824
user24051824

Reputation: 1

How do I delete contact use contentResolver in android?

I'm a beginner in Android and I'm having a problem with this code. When I run it, it can only delete the contact's phone number but can't completely delete the contact. How do I fix it? Please help me.

ContentResolver contentResolver = activity.getContentResolver();
        long id = c.getId();
        Uri uri= ContentUris.withAppendedId(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI, id);
        String selection = ContactsContract.Contacts._ID + " = ?";
        String[] selectionArgs  = new String[]{String.valueOf(id)};
        contentResolver.delete(
                uri,
                selection,
                selectionArgs
        );

Upvotes: 0

Views: 27

Answers (0)

Related Questions