I insert a contact. How to get the row contact Id?
//insert a contact
ops.add(ContentProviderOperation
.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
.build());
// insert email, phone, structuredpostal and other
// things of the contact using withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
cr.applyBatch(ContactsContract.AUTHORITY, ops);
ContentProviderResult[] res = cr.applyBatch(ContactsContract.AUTHORITY, ops);
if (null != res){ id = res[0].uri.getLastPathSegment();}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.