part of contact are repeated after each writing the same contact (Android 2.0+)
- by Bogus
Hello,
I met this problem at writing contacts by API for Android 2.0 or greater.
Each time I write the same contact which already exist in my account (Google
account) I got some part of contact aggregated ok but
other did not. For example fields like FN, N, ORG, TITLE always are in one
copy but TEL, EMAIL, ADR are added extra so after 2nd writing the same contact I have
2 copy the same TEL or EMAIL. How to force API engine to not repeate existed data ?
Code:
ArrayList ops = new ArrayList();
ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, accountType)
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, accountName)
.build());
...
// adding phone number
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0);
builder.withValue(ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
builder.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, phoneValue);
builder.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, phoneType); // work/home
builder.withValue(ContactsContract.CommonDataKinds.Phone.LABEL, phoneLabel);
ops.add(builder.build());
...
try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
//
}
I tried add: AGGREGATION_MODE on AGGREGATION_MODE_DISABLED.
but it changed nothing.
I will glad for any hint in this case.
BR, Bogus