在 Android 中,如何仅使用自定义同步适配器从自定义帐户中删除联系人?
我创建了一个自定义同步适配器,但每次我使用该适配器删除联系人时(例如,在服务器上删除联系人时),它也会删除其他帐户中的所有聚合联系人。目前,我只使用 ContentResolver.delete(...)
方法。有没有办法指定我不想删除自定义帐户的联系人?
I've created a custom sync adapter, but every time I delete a contact using that adapter (when a contact is deleted on the server, for example), it also deletes all aggregate contacts from other accounts. Currently, I just use the ContentResolver.delete(...)
method. Is there a way to specify that I donly want to delete my custom account's contact?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我发现了——默认情况下,Android 会聚合所有联系人,因此当我删除一个自定义同步联系人时,联系人 ID 会与所有其他聚合联系人相匹配,这就是它们被删除的原因。如果我使用
.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED)
告诉同步适配器添加 ti 时不要聚合联系人,那么我的所有自定义联系人都可以自行删除Nevermind, I figured it out -- by default, Android aggregates all the contacts, so when I delete one of my custom synched contacts, the contact ID matches all the other aggregate contacts, and that's why they were being deleted. If I tell the contact not to be aggregated when ti's being added by the sync adapter by using
.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED)
, then all my custom contacts can be deleted by themselves