如何将联系人添加到组? [英] how to insert contact to a group?

查看:191
本文介绍了如何将联系人添加到组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆