I'm not sure if this is a bug in Android, a bug in the emulator, or a bug in my code. I have a syncadpter that creates a few groups and populates them with raw contacts. The code works as expected on a freshly booted emulator. If I delete the syncadapter's account the groups and contacts are deleted as expected. However, if I then add the account back, the groups and contacts are recreated just fine, but are not linked together properly. Based on looking at the contacts db with the adb shell, it seems that the GroupMembership data rows (which were added with the GROUP_SOURCE_ID parameter) are using the group_row_ids from when the groups were created the first time. So it looks like there is a stale GROUP_SOURCE_ID -> GROUP_ROW_ID cache being used somewhere. Does this look like a platform bug, or is there an api for clearing such a cache I should be using?
Thanks, Jay This is the inner loop of my contact create code. The necessary groups have already been created. // Contact does not exist; create him final int backRef = batch.size(); batch.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) .withYieldAllowed(true) .withValue(RawContacts.ACCOUNT_TYPE, account.type) .withValue(RawContacts.ACCOUNT_NAME, account.name) .withValue(RawContacts.SOURCE_ID, serverId).build()); // Attach names batch.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) .withValueBackReference(Data.RAW_CONTACT_ID, backRef) .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) .withValue(StructuredName.GIVEN_NAME, contact.getGiven()) .withValue(StructuredName.FAMILY_NAME, contact.getFamily()).build()); // Attach groups for (final long groupServerId : contact.getGroups()) { batch.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) .withValueBackReference(Data.RAW_CONTACT_ID, backRef) .withValue(Data.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE) .withValue(GroupMembership.GROUP_SOURCE_ID, groupServerId).build()); } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en