ContentProvider 适合非常动态的数据吗?
我是一名 Android 新手,通过创建一些基本应用程序来学习 SDK。我目前正在开发一个应用程序,该应用程序将显示来自新闻聚合器的内容,其中包含新闻项目和每个项目的评论。每个新闻项目都有一个“id”,以及许多与之相关的评论。
每个结果页面将分别在页面开头和结尾处有一个对新闻项的“之前”和“之后”引用 ID。因此每个“查询”将类似于“/?before=$ID”或“/?after=$ID”。
ContentProvider 似乎是 Android 上存储数据的首选方式。然而,网站的内容变化如此之大,以至于我怀疑使用 ContentProvider 是否明智。
我很欣赏任何见解。
I'm an Android newbie, learning the SDK by creating some basic apps. I'm currently working on an app that will display content from a news aggregator with news items and comments on each item. Each news item has an 'id', and many comments associated with it.
Each results page will have a 'before' and 'after' reference id to the news item at the beginning of the page and the end, respectively. So each 'query' will be something like '/?before=$ID' or '/?after=$ID'.
It seems like ContentProviders are the preferred way to store data on android. However, the content of the site changes so much that I question whether or not using a ContentProvider would be wise.
I appreciate any insight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,内容提供商被电子邮件应用程序用来保存电子邮件,gmail 用来存储和同步其邮件消息,gtalk 和联系人用来跟踪您认识的人及其聊天状态等。
我不确定如何使用你所想的是动态的,但这些都是非常动态的。
一种看待它的方式是:内容提供商只是一个跨流程访问结构化数据的 API。如果该 API 满足您的目的,那么这是一个好兆头。它们的另一个方面是它们通常是在 SQLite 数据库之上实现的,这是实现它们的最简单方法,因为有很多框架对此提供支持。因此,您很可能会为您的内容提供商实现使用 SQLite 数据库。数据库的动态性对您来说足够吗?
Well content providers are used by the e-mail app to hold e-mail, gmail to store and sync its mail messages, gtalk and contacts to keep track of the people you know and their chat status, etc.
I am not sure just how dynamic you are thinking, but those are all pretty dynamic.
One way to look at it -- a content provider is just an API to access structured data across processes. If that API serves your purpose, well that's a good sign. The other aspect to them is that usually they are implemented on top of a SQLite database, and that is the easiest way to implement them because there is a lot of framework support for that. So you will most likely be using a SQLite database for your content provider impl. Is a database dynamic enough for you?