简体   繁体   English

同步Android联系人

[英]Sync Android contacts

I am making an app that fetch all contacts and save it my db which is working perfectly. 我正在制作一个应用程序来获取所有联系人并保存我的数据库,这是完美的。

Now whenever user do CRUD operation in native i want that to be observed by my app so that i can update in my db too. 现在,每当用户在本机中进行CRUD操作时,我希望我的应用程序能够观察到这一点,以便我也可以在我的数据库中进行更新。 So after lot of research i found there is no way to know which particular contact has been updated or deleted. 因此,经过大量研究,我发现无法知道哪个特定联系人已被更新或删除。

So i compared the CONTACT_LAST_UPDATED_TIMESTAMP of contact with my sync time. 所以我将联系人的CONTACT_LAST_UPDATED_TIMESTAMP与我的同步时间进行了比较。

Now the issue am facing is with Google sync that runs every 20 minutes and update all contacts CONTACT_LAST_UPDATED_TIMESTAMP. 现在面临的问题是每隔20分钟运行一次Google同步并更新所有联系人CONTACT_LAST_UPDATED_TIMESTAMP。 It makes me to update all those contacts 它让我更新所有这些联系人

Is there any other possible way to achieve syncing (to get particular contact that has been updated). 是否有任何其他可能的方法来实现同步(以获得已更新的特定联系人)。 Tried Sync adapter, tells only change in URI not particular contact. 尝试同步适配器,仅告知URI中的更改而不是特定的联系人。

Any help or lead will be appreciated. 任何帮助或领导将不胜感激。 Thanks 谢谢

One way would be to keep a local copy of contacts db only needed information like id and version . 一种方法是保持联系人db的本地副本只需要idversion等信息。

Here ' version ' is an interesting column which is increased everytime there is a change in the contact. 这里的' 版本 '是一个有趣的专栏,每当联系人发生变化时,该专栏都会增加。 so you can use this to find out exactly which one is changed. 所以你可以使用它来确切地找出哪一个被改变了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM