SecurityException Permission Denial MediaProvider READ_EXTERNAL_STORAGE

牧云@^-^@ 提交于 2019-12-24 03:53:16

问题


i am making gallery.

i got below exception

Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=23769, uid=10470 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()

I added permission

  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"  />

in my AndroidMainfest

my code is below :

  Cursor localCursor = MediaStore.Images.Media.query(getContentResolver(), uri, mQuery);

i using nexus 5 (android ver 6.0) help!!


回答1:


The permission model changed with Android Marshmallow. You should read this https://developer.android.com/training/permissions/requesting.html article first! Most of your question will be answered.



来源:https://stackoverflow.com/questions/33122512/securityexception-permission-denial-mediaprovider-read-external-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!