I have one existing contact, I need to add a work address to that existing contact. I am using the following code, but it's not working.
String selectPhone = Data.CONTACT_ID + "=? AND " + Data.MIMETYPE + "='" +
ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE +
"'" + " AND " + ContactsContract.CommonDataKinds.StructuredPostal.TYPE + "=?";
String[] phoneArgs = new String[]
{String.valueOf(ContactId), String.valueOf(
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK)};
ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
.withSelection(selectPhone, phoneArgs)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.STREET, STREET)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.CITY, CITY)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.REGION, REGION)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE, POSTCODE)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, COUNTRY)
.build());
this.context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
Any solution for this?