允许用户只能访问自己的内容提供商一定的表 [英] Allow users to only access certain tables in my content provider
问题描述
我打算为我的应用程序数据库。
I'm planning the database for my app.
我想允许他人使用我的数据。不过,我只希望他们能够访问情侣表。是否有可能只允许其他应用程序访问某些表?
I would like to allow others to use my data. However, I only want them to access a couple tables. Is it possible to only allow other apps to access certain tables?
有我所有的分贝code在一个地方(内容提供商)只是似乎是一个好主意,而不是将其拆分。
Having all my db code in one place (content provider) just seems like a good idea, rather than having to split it up.
什么会被认为是最佳做法?
What would be considered best practice?
推荐答案
在你的Android清单文件,你应该为属性 grandUriPermissions
设置为<$ C您的内容提供者的标签$ C>假。因此,你会保护你的内容提供商的所有数据的访问。之后,在&LT;提供商GT; &LT; /提供商GT;
您应该添加标签&LT;赠款URI的权限&GT;
。关于它的属性,你可以阅读这里。 (你的情况,我想,是路径preFIX属性)
In your Android Manifest file you should for your content provider tag set an attribute grandUriPermissions
to false
. Thus, you will protect all data of your content provider from access. After that inside <provider> </provider>
you should add tag <grant-uri-permission>
. About its attribute you can read here. (Your case, I guess, is pathPrefix attribute)
这篇关于允许用户只能访问自己的内容提供商一定的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!