I searched and read android developer files but I did not find any satisfactory answer for content provider grant uri permission. Can anybody explain more detailed and more simple. My questions are: What grant uri is using for? What is the differences between grant uri permission true and false When we should use true? when false? and any more detail are appreciated.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Why using href=“// instead of href=”http:// in HTM
Say you need to mail some file that is on your application cache directory.
No other apps can access that file, unless you specify that other apps can access content of your application. For this you create content provider, and say, all uri's in form content://com.your.app/file you 'redirect' to your application cache directory.
Some code:
As CommonsWare said:
The "grant
Uri
permissions" feature allows you to have aContentProvider
that is normally inaccessible by third parties, yet selectively allow access to individualUri
values to individual third-party apps for a short period of time (e.g., long enough to view the PDF that the provider serves).android:grantUriPermissions="true"
indicates that your Java code can useFLAG_GRANT_READ_URI_PERMISSION
andFLAG_GRANT_WRITE_URI_PERMISSION
for anyUri
served by thatContentProvider
.android:grantUriPermissions="false"
indicates that only theUri
values specified by child<grant-uri-permission>
elements can be used withFLAG_GRANT_READ_URI_PERMISSION
andFLAG_GRANT_WRITE_URI_PERMISSION
.