Android自定义ContentProvider
是否可以创建一个自定义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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短回答:是
较长回答:
ContentProviders
是位于“外部世界”(例如其他 AndroidActivities
)和后端数据存储之间的一层。您永远无法直接访问数据库。数据库存储在Activities
私有存储空间中。因此,您所能做的就是由您正在寻址的ContentProvider
决定。如果
ContentProvider
只允许对数据进行只读访问,那么您就只能这么做了。因此,最终,您只能提供最多与您正在使用的
ContentProvider
相同的访问权限。但是,您可以公开不同的数据结构。或者,您也可以创建一个在内部使用多个其他提供程序的ContentProvider
。归根结底,在给定的范围内,你的想象力就是极限。
Short Answer: Yes
Longer answer:
ContentProviders
are a layer sitting in between the "outside world" (e.g. other AndroidActivities
) and the back-end data storage. You will never have direct access to the database. The database is stored in theActivities
private storage space. So all you can do is dictated by theContentProvider
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 oneContentProvider
which uses multiple other providers internally.On the bottom line, within the given bounds, your imagination is the limit.