将 Android 联系人与服务器同步 - 同步算法
我想将我的 Android 设备的联系人与服务器同步(单向同步:根据设备的联系人数据库更新服务器)。
我看过 SampleSyncAdapter 示例: http://developer.android.com/resources/samples/SampleSyncAdapter/index.html
以及一个非常好的博客,可以帮助您理解拼图中的各个部分: http://ericmiles.wordpress.com/ 2010/09/22/connecting-the-dots-with-android-syncadapter/
我知道同步逻辑本身应该覆盖 onPerformSync()在扩展 AbstractThreadedSyncAdapter 的类中。
然而,我无法找到同步算法的示例。 例如,如何仅同步与上次同步的差异?我是否应该为最新同步的联系人保留缓存并将其与当前的联系人数据库进行比较?
I want to sync my android device's contacts with a server (1-way syncing: update server according to the device's contacts DB).
I've seen the SampleSyncAdapter example:
http://developer.android.com/resources/samples/SampleSyncAdapter/index.html
and a very good blog for understanding the pieces in the puzzle:
http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/
I understand that the sync logic itself is supposed to be in overriding onPerformSync() in a class extending AbstractThreadedSyncAdapter.
I was not, however, able to find an example for the syncing algorithm.
For instance, how do I sync just the diffs from the previous sync? am I supposed to keep a cache for the latest synced contacts and diff it with the current contacts DB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
理想情况下,您将大部分工作卸载到服务器上。
如果您谈论的是 REST api 类型的服务器,您有两个选择。
如果他们的 REST API 不支持,
Ideally, you offload much of that work to the server.
If you're talking about a REST api type of server, you have two options.
If that isn't supported by their REST API,