Hi, I'm developing an application that should add a custom raw_contact to an existing contact on the Android contacts DB. Let's consider the following values on the native raw_contact: contact_id=7250, number=+351910000018
Given this, I use the code bellow to create my application's raw_contact: ArrayList<ContentProviderOperation> operationList = new > ArrayList<ContentProviderOperation>(); > ContentProviderOperation.Builder builder; > > // build raw contact id > builder = ContentProviderOperation.newInsert(RawContacts.CONTENT_URI); > builder.withValue(RawContacts.ACCOUNT_TYPE, "org.example.account"); > builder.withValue(RawContacts.ACCOUNT_NAME, "Dummy account name"); > builder.withValue(RawContacts.SYNC1, "+351910000018"); > operationList.add(builder.build()); > > // associate a phone to raw contact > builder = ContentProviderOperation.newInsert(Data.CONTENT_URI); > builder.withValueBackReference(Data.RAW_CONTACT_ID, 0); > builder.withValue(Data.MIMETYPE, CommonDataKinds.Phone.CONTENT_ITEM_TYPE); > builder.withValue(Phone.NUMBER, "+351910000018"); > builder.withValue(Phone.TYPE, Phone.TYPE_CUSTOM); > operationList.add(builder.build()); > > mProvider.applyBatch(operationList); > > // create the aggregation exception > operationList.clear(); > builder = > ContentProviderOperation.newUpdate(ContactsContract.AggregationExceptions.CONTENT_URI); > builder.withValue(AggregationExceptions.TYPE, > AggregationExceptions.TYPE_KEEP_TOGETHER); > builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, <custom raw > contact ID>); > builder.withValue(AggregationExceptions.RAW_CONTACT_ID2, <native raw > contact ID>); > operationList.add(builder.build()); > > mProvider.applyBatch(operationList); > After running this, we can see the following data inserted on the contacts DB: * Table: "raw_contacts"* > _id account_name account_type > contact_id > 7250 - - > *7250* > 7254 Dummy account name org.example.account *7254* > > *Table: "data"* > _id raw_contact_id data1 > 31663 7250 +351910000018 > 31664 7254 +351910000018 > > *Table: "agg_exceptions"* > _id type raw_contact_id1 raw_contact_id2 > 20 1 7250 7254 > As you can see, all the data seems to be OK except the contact_id fields (as they don't match). Given this, the native contact list can't merge the raw_contacts (please find a screenshot attached). Note 1: As I have a rooted terminal, I dicided to modify the native contacts DB (contacts2.db) and set both raw_contact's contact_id field to the same value. After this change, the contact integration occurs as expected. Note 2: This works well with Samsung Galaxy S devices (between others) How can I solve this issue? As the contact_id field is set by the ContactsProvider, I can't ever hardcode it during the build operation. Has anyone experienced this before? Please ask me if you need any additional information. Thanks a lot, Miguel Pragosa -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
<<attachment: device-2012-07-24-121609.png>>

