java.lang.SecurityException

Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=27738, uid=10158 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()

Samebug tips5

Android SDK 23 introduced a new way to handle permissions, so as a temporary workaround you can set it to build for SDK below 23. As a permanent solution you have to ask user during runtime for permissions with checkSelfPermission() or requestPermissions()


rafaelrafael

You need the permission android.permission.READ_EXTERNAL_STORAGE. Write <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> on the Android Manifest


rafaelrafael

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web1299

  • via Stack Overflow by user3655773
    ,
  • Stack trace

    • java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=27738, uid=10158 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission() at android.os.Parcel.readException(Parcel.java:1599) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476) at android.content.ContentResolver.insert(ContentResolver.java:1251) at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:971) at com.scanlibrary.Utils.getUri(Utils.java:23) at com.scanlibrary.PickImageFragment.postImagePick(PickImageFragment.java:146) at com.scanlibrary.PickImageFragment.onActivityResult(PickImageFragment.java:141) at android.app.Activity.dispatchActivityResult(Activity.java:6487) at android.app.ActivityThread.deliverResults(ActivityThread.java:3738) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3785) at android.app.ActivityThread.access$1400(ActivityThread.java:157) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5525) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Unknown visitor
    Unknown visitorOnce,
    balajivaishnavbalajivaishnav
    Once,
    Hiren AmaliyarHiren Amaliyar
    669 times, last one
    filipebatistafilipebatista
    48 times, last one
    SacchiSacchi
    138 times, last one
    230 more bugmates