合并原始联系人 [英] Merging raw contacts

查看:98
本文介绍了合并原始联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个帐户和一个同步适配器,它们添加了带有相应私人数据条目的新原始联系人. 我正在创建的联系人是基于电话号码的,这意味着我正在为每个现有电话号码创建一个新条目.

I have an account and a sync adapter which add new raw contacts with corresponding private data entries. the contacts I'm creating are phone number based, meaning I'm creating a new entry per existing phone number.

我尝试在数据表中创建一个新的电话号码条目,并将其链接到我要添加的原始联系人.可以,但是它正在创建一个重复的电话号码.

I've tried creating a new phone number entry in the data table, and link it to the raw contacts I'm adding. it works, but It's creating a duplication phone number.

我也尝试设置联系人ID,显示名称,第二显示名称,但没有成功...我只能在原始联系人中更改的数据是帐户名称和类型,以及SYNC1 ... SYNC4列

I've also tried setting the contact ID, display name, secondery display name but with no success... the only data I can change in raw contacts is the account name and type, and the columns SYNC1...SYNC4

推荐答案

您需要更新AggregationExceptions表中的条目. 请参阅: http://developer.android.com/reference/android/provider/ContactsContract.AggregationExceptions.html

You need to update an entry in the AggregationExceptions table. See: http://developer.android.com/reference/android/provider/ContactsContract.AggregationExceptions.html

如果需要,可以支持批量加入的示例代码:

An example code that supports batch joining if needed:

ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
Builder builder = ContentProviderOperation.newUpdate(AggregationExceptions.CONTENT_URI);
builder.withValue(AggregationExceptions.TYPE, AggregationExceptions.TYPE_KEEP_TOGETHER);
builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, raw1);
builder.withValue(AggregationExceptions.RAW_CONTACT_ID2, raw2);
operations.add(builder.build());
contentResolver.applyBatch(ContactsContract.AUTHORITY, tempArrayList);

这篇关于合并原始联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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