Android自定义ContentProvider

发布于 2024-08-08 15:02:58 字数 192 浏览 4 评论 0原文

是否可以创建一个自定义ContentProvider

  • 访问android现有数据库(例如联系人、短信)?
  • 扩展一个可以访问android现有数据库的令人兴奋的ContentProvider(例如ContactsProvider来访问Contacts DB)?

谢谢。

Is it possible to create a custom ContentProvider to

  • Access android existing database (e.g. Contacts, SMS)?
  • Extend an Exciting ContentProvider which has access to android existing database (e.g. ContactsProvider to access Contacts DB)?

Thank you.

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

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

发布评论

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

评论(1

深白境迁sunset 2024-08-15 15:02:58

简短回答:是

较长回答:

ContentProviders 是位于“外部世界”(例如其他 Android Activities)和后端数据存储之间的一层。您永远无法直接访问数据库。数据库存储在Activities私有存储空间中。因此,您所能做的就是由您正在寻址的 ContentProvider 决定。

如果 ContentProvider 只允许对数据进行只读访问,那么您就只能这么做了。

因此,最终,您只能提供最多与您正在使用的 ContentProvider 相同的访问权限。但是,您可以公开不同的数据结构。或者,您也可以创建一个在内部使用多个其他提供程序的 ContentProvider

归根结底,在给定的范围内,你的想象力就是极限。

Short Answer: Yes

Longer answer:

ContentProviders are a layer sitting in between the "outside world" (e.g. other Android Activities) and the back-end data storage. You will never have direct access to the database. The database is stored in the Activities private storage space. So all you can do is dictated by the ContentProvider you are addressing.

If the ContentProvider only allows read-only access to the data, than that is all you can do.

So in the end, you can only offer access which has at most the kind of access as the ContentProvider you are using. You can however expose a different data structure. Or you could also create one ContentProvider which uses multiple other providers internally.

On the bottom line, within the given bounds, your imagination is the limit.

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