[英]How to get row contact id after insert?
我插入一個聯系人。 如何獲取行聯系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();}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.