[英]Provide contacts from ContentProvider to standard Contact app
I've tried to search, but I even can't ask the question in short form.我试图搜索,但我什至不能以简短的形式提出问题。
SQLite
table with id/username/mobile/email.SQLite
表。ContentProvider
for it.ContentProvider
。All of it working and I can create contacts using my function Sqlite2Contacts
.所有这些都有效,我可以使用我的函数
Sqlite2Contacts
创建联系人。 Ie each of SQLite
record I provide to ContactsContract
with my Account name and type.即我提供给
ContactsContract
每条SQLite
记录都带有我的帐户名称和类型。 All contacts visible through standard application and when I remove account all contacts also removed.通过标准应用程序可见的所有联系人,当我删除帐户时,所有联系人也被删除。
All working fine, but... I think I've missed something.一切正常,但是......我想我错过了一些东西。 I suppose that should be some framework for It.
我想这应该是它的一些框架。
Ie I bind my ContentProvider to... something using some sort of adapter without manual contacts synchronization.即我将我的 ContentProvider 绑定到...使用某种适配器而无需手动同步联系人的东西。
I need the only answer can I do it or no, not implementation.我需要唯一的答案是我能不能做,而不是执行。 And if I can... what class/framework/adapter should I use.
如果可以的话……我应该使用什么类/框架/适配器。
Sounds like you're in the wrong direction, you should not be putting your app's contacts in a ContentProvider
.听起来您走错了方向,您不应该将应用程序的联系人放在
ContentProvider
。
To put app specific contacts in the Contacts DB in Android your app needs two components: Account and SyncAdapter.要将特定于应用程序的联系人放入 Android 的联系人数据库中,您的应用程序需要两个组件:帐户和 SyncAdapter。
The Account
allows the user to authenticate (if needed) and to manually remove / sync your app's contacts.该
Account
允许用户进行身份验证(如果需要)并手动删除/同步您的应用程序的联系人。 The SyncAdapter
is called by the system or programatically by your app and syncs RawContacts
into the Contacts DB under your app's ACCOUNT_TYPE
+ ACCOUNT_NAME
. SyncAdapter
由系统调用或由您的应用程序以编程方式调用,并将RawContacts
同步到您应用程序的ACCOUNT_TYPE
+ ACCOUNT_NAME
下的联系人数据库中。
There are two tutorials by Udi you can follow:您可以遵循 Udi 的两个教程:
And the official tutorial here:官方教程在这里:
https://developer.android.com/guide/topics/providers/contacts-provider.html https://developer.android.com/guide/topics/providers/contacts-provider.html
(under How to write a sync adapter for synchronizing data from your server to the Contacts Provider
) (在
How to write a sync adapter for synchronizing data from your server to the Contacts Provider
下)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.