对使用同步适配器和内容提供程序同步多个表感到困惑

发布于 2024-12-12 06:07:28 字数 341 浏览 0 评论 0原文

我很困惑哪种方式是在我的应用程序中同步多个表的最佳方式。

我有一个内容提供商,并打算拥有多个表(事件、用户等)。我还有一个应用程序应该与之通信的休息服务器。我想知道处理每个表的多个连接(放置、获取、发布和删除)的最佳实践是什么。他们也有关系,就像一个用户可以参加一个活动,但也可以成为该活动的所有者。因此,如果我创建了一个用户和该用户的所属事件,我可以上传该用户,从服务器获取有关该用户的信息,上传包含有关该用户的信息的事件,获取该信息,然后更新用户获得新的事件信息。

解决这些问题的最佳方法是什么?我应该创建一个方法(http://example.com/sync)来聚合所有应该同步的数据吗?或者我应该坚持,有时〜15-20个请求?

I'm confused about which way is the best to have multiple tables get synced in my application.

I have one content provider and intend to have multiple tables (events, users, etc). I also have a rest-server that the app is supposed to communicate with. I'm wondering about what is the best practice to handle multiple connections (put, get, post and delete) for each of the tables. They have also relationships, like one user can be attending an event, but also be the owner of the event. So if I have created a user and a belonging event to that user, I can either upload the user, get back info from the server about the user, upload the event with the information about the user, get back that information and then update the user with the new event information.

What is the best way to solve these problems? Should I create a method (http://example.com/sync) that aggregates all the data that should be synced? Or should I just stick with, sometimes ~15-20 requests?

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

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

发布评论

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

评论(3

甜味拾荒者 2024-12-19 06:07:28

Evernote 通过其专有的 EDAM 协议解决了类似的问题。值得研究一下。

Evernote EDAM

Evernote has solved a similar problem with their proprietary EDAM protocol. Worth looking into.

Evernote EDAM

作业与我同在 2024-12-19 06:07:28

我建议您观看 Google I/O 2010 - Android REST 客户端应用程序视频。
这是对编写良好设计同步应用程序的一些概念和推荐模式的精彩介绍。

我个人找到了大部分问题的答案。

另请参阅此演示文稿。除了本演示文稿和随 SDK 提供的同步适配器示例之外,下面的列表应该为您提供充足的资料,让您能够相当快速地启动和运行同步适配器。

I would recommend you to watch Google I/O 2010 - Android REST client applications video.
It’s a fantastic introduction into some of the concepts and recommended patterns for writing well design syncing applications.

I personally found answers to most of my questions.

Also look this presentation. Along with this presentation and the sync adapter sample provided with the SDK, the following list should provide you ample ammunition to get a sync adapter up and running fairly quickly.

一片旧的回忆 2024-12-19 06:07:28

这完全取决于您要同步的数据量。

如果只是文本数据,而且数量不多,您应该一次性同步所有数据。我建议将其全部编码为 json,压缩并将其发送到服务器(您将在其中解压缩、解析和保存)。 Json 是轻量级的,很容易在 android 上编写,并且可以在几乎任何类型的服务器上解析。

如果您想同步图像,最好一次同步一张,以确保在连接断开时保存部分进度。

It all depends on the amounts of data you want to sync.

If it's only text data, and not a lot, you should sync it all at once. I would recommend encoding it all to json, zipping it and sending it to the server (where you would unzip, parse and save). Json is lightweight and easy to compose on androi, as well as to parse on almost any kind of server.

If you want to sync images, you'd be better off syncing them one at a time, to be sure you have partial progress saved in case the connection drops.

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