联系人备份和同步应用程序

发布于 2024-10-27 19:36:58 字数 685 浏览 1 评论 0原文

我正在研究联系人备份和同步。

目标是将所有联系人的所有详细信息发送到服务器(定义的自定义协议)作为备份。

在应用程序首次启动期间,所有联系人都将排队并发送到服务器。 之后,后台服务将一直运行,它将侦听新的联系人添加/联系人更新,并且该新的/更新的联系人将由后台服务发送到服务器。

我正在使用 RawContactsEntity 来获取记录。

我尝试在 RawContacts/Data 表上使用 ContentObserver 来获取联系人添加或联系人更改的通知。但是,据我所知,ContentObserver 会通知 (onChange()) 表中整个数据的更改,而不是单个记录的 ID。

现在我的问题是,如何获取更改/新记录的确切 ID?

我想创建一个备份表来与本机联系人表进行比较并获取更改的记录。但随着触点数量的增加,性能将急剧下降,这也会影响电池寿命。

您能否建议我,从性能和内存使用的角度来看,实现此联系人备份操作的最佳方法? 还有其他方法可以进行联系人同步操作吗?

如果有人可以分享可以帮助我的例子,那将非常有帮助。

I am working on a contacts backup and sync.

The target is to send all details of all contacts to a server (custom protocol defined) as a backup.

During initial launch of application, all the contacts will be queued and sent to the server.
And after that, a background service will be running all time which will listen to new contact addition/ contact update, and this new/updated contact will be sent to server by the background service.

I am using RawContactsEntity for fetching the records.

I tried using ContentObserver on RawContacts/Data tables to get notification of contact addition or contact-change. But, AFAIK, the ContentObserver gives notification (onChange()) of changed data in table as a whole and not ID of individual record.

Now my problem is, how to get the exact id's of changed/new records?

I thought of creating a backup-table to compare with native contacts table and get the changed records. But as the number of contacts increase, the performance will decease drastically and this will hamper the battery life too.

Can you suggest me, The best way for achieving this contacts backup operation from performance and memory usage point of view?
Is there any other way for contacts sync operation?

It would be very helpful if anyone can share examples which can help me in this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剧终人散尽 2024-11-03 19:36:58

如果联系人存储在您的帐户 (AccountManger) 中,Android 会标记原始联系人中的脏标志。如果这不是您的帐户,则您不能信任脏标志,因为帐户同步适配器可能已将联系人更新到服务器并重置脏标志。您唯一的选择是重新上传完整的联系人(简单且易于编码)或跟踪 RawContacts 中的版本列并检查哪一个已更改。实际上不建议从其他帐户复制和上传联系人,因为相应的同步适配器无论如何都会维护这些联系人的备份。就像谷歌一样,他们的服务器上也会有谷歌联系人的副本。

If the contacts are stored within your account(AccountManger), Android will mark the dirty flag in raw contacts. If it is not your account then you can not trust the dirty flag as the accounts sync adapter might have updated the contact to the server and reset the dirty flag. Your only option is to either re-upload the full contacts(simple and easy to code) or keep track of the version column in RawContacts and check which one has changed. It is actually not recommended to copy and upload contacts from other accounts as the corresponding sync adapter will anyways maintain a backup of those. Like Google will have a copy of Google contacts on their server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文