我插入一个联系人。如何获得行联系人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);
答案 0 :(得分:0)
ContentProviderResult[] res = cr.applyBatch(ContactsContract.AUTHORITY, ops);
if (null != res){ id = res[0].uri.getLastPathSegment();}