SecurityException Permission Denial MediaProvider

2019-07-10 14:18发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-07-10 14:39

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.

查看更多
登录 后发表回答