0

i'm trying to implement sharing option into my application and to share images via different social networks, but i'm getting this error when i try to save image first from ImageView and then read it:

Failed to insert image java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri 
content://media/external/images/media from pid=9758, uid=10176 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()

This is my manifest file:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
    android:name=".app.AppController"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

And gradle file:

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.dusandimitrijevic.pdssolution"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 3
    versionName "1.2"

    // Enabling multi dex support.
    multiDexEnabled true

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

Dusan Dimitrijevic
  • 3,169
  • 6
  • 22
  • 46

1 Answers1

1

This error are showing for target version 23 then it will give you this error, if your requirement includes API level 23 then you need to make target 23 and need to check permissions dynamically here is the example from developer site check developer site

Here is permissions list.

Even if you give target 22 or lower also your app will work with 23 without this(check permission) error.

Md. Sajedul Karim
  • 6,749
  • 3
  • 61
  • 87