Merging Raw Contacts
I have an account and a sync adapter which add new raw contacts with corresponding private data entries. the contacts I'm creating are phone number based, meaning I'm creating a ne
Solution 1:
Raw contacts table holds 1 row per contact, Data table may hold any number of rows for each row in Raw table.
To add new phone numbers to a contact, Insert rows in Data table with ContactsContract.Data.RAW_CONTACT_ID
set to the Raw table row _id
of that contact.
Solution 2:
You need to update an entry in the AggregationExceptions table. See: http://developer.android.com/reference/android/provider/ContactsContract.AggregationExceptions.html
An example code that supports batch joining if needed:
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
Builder builder = ContentProviderOperation.newUpdate(AggregationExceptions.CONTENT_URI);
builder.withValue(AggregationExceptions.TYPE, AggregationExceptions.TYPE_KEEP_TOGETHER);
builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, raw1);
builder.withValue(AggregationExceptions.RAW_CONTACT_ID2, raw2);
operations.add(builder.build());
contentResolver.applyBatch(ContactsContract.AUTHORITY, tempArrayList);
Post a Comment for "Merging Raw Contacts"