jcmhong
jcmhong

Reputation: 88

SecurityException Permission Denial MediaProvider READ_EXTERNAL_STORAGE

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!!

Upvotes: 3

Views: 6150

Answers (1)

Thomas R.
Thomas R.

Reputation: 8063

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.

Upvotes: 2

Related Questions