如何将联系人添加到组? [英] how to insert contact to a group?
问题描述
我想通过使用 ContactsContract.Groups._ID <添加
联系人
来我有所有的组名和其ID的特定组/ code>,现在我想通过这个 ID为
。即插入一些联系人
添加到组接触ID
一些组ID
。
I want to add a contact
to a specific group I am having all the group names and their Id's by using ContactsContract.Groups._ID
, now I want to add a contact
to a group by this id
. i.e insert some contact id
to some group id
.
我已经取回团体和原料接触的ID,请告诉我查询做到这一点。
I have retrieved both group and Raw contact id's please tell me the query to do this.
谢谢!
问候,
穆罕默德·塔希尔阿什拉夫。
regards, Muhammad Tahir Ashraf.
推荐答案
我已经找到了答案在<一个href=\"http://stackoverflow.com/questions/2491546/how-do-i-add-contact-to-a-group-on-android.Thanks\">How我在Android上添加联系人到组?来Pentium10
I have found the answer at How do I add contact to a group on Android? to Pentium10
public Uri addToGroup(long personId, long groupId) {
//remove if exists
// this.removeFromGroup(personId, groupId);
ContentValues values = new ContentValues();
values.put(ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID,
personId);
values.put(
ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID,
groupId);
values
.put(
ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE,
ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE);
return this.ctx.getContentResolver().insert(
ContactsContract.Data.CONTENT_URI, values);
}
这篇关于如何将联系人添加到组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!