How to update a particular email Address in contacts?

Viewed 26

i use the following the code to update the number:

ContentValues mobilePhoneValues = new ContentValues();
        mobilePhoneValues.put(ContactsContract.CommonDataKinds.Phone.TYPE, typePhone);
        mobilePhoneValues.put(ContactsContract.CommonDataKinds.Phone.NUMBER, binding.numberEdit.getText().toString());
        getContentResolver().update(ContactsContract.Data.CONTENT_URI, mobilePhoneValues,
       ContactsContract.CommonDataKinds.Phone.NUMBER + "=?", new String[]{mobilePhoneNumbers.get(0)});

It works perfectly but when i try to update the email using same logic it fails to update it. Code:

 ContentValues contentValues1 = new ContentValues();
        contentValues1.put(ContactsContract.CommonDataKinds.Email.TYPE, typeEmail);
        contentValues1.put(ContactsContract.CommonDataKinds.Email.DATA, binding.emailEdit.getText().toString());
        getContentResolver().update(ContactsContract.Data.CONTENT_URI, contentValues1,
        ContactsContract.CommonDataKinds.Email.DATA + "=?", new String[]{homeEmailNumbers.get(0)});

Why is it the same logic updates the number but fails to update the email ? Please help

0 Answers
Related