views:

8

answers:

0

If you are using incremental approach in adding a record to Contacts Data table, after an insertion, you get the URL of the newly added record so that you can perform query or update operation.

Now if you are using batch operation like following, how do you get the reference to the newly added record?

            // Create RawContacts table
            ops.add(ContentProviderOperation
                    .newInsert(ContactsContract.RawContacts.CONTENT_URI)
                    .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE,
                            "com.javapassion")
                    .withValue(ContactsContract.RawContacts.ACCOUNT_NAME,
                            "[email protected]").build());

            // Create entry in the Data table
            ops.add(ContentProviderOperation
                    .newInsert(ContactsContract.Data.CONTENT_URI)
                    .withValueBackReference(
                            ContactsContract.Data.RAW_CONTACT_ID, 0)
                    .withValue(
                            ContactsContract.Data.MIMETYPE,
                            ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
                    .withValue(
                            ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
                            "Lady Gaga").build());

related questions