Search code examples
androidfile-permissionsfilenotfoundexceptionandroid-sdcardpermission-denied

Android write to secondary external storage (Permission denied)


When I am trying to write to a file in secondary external storage (SD Card), I am getting the following error:

java.io.FileNotFoundException: /storage/70F7-83E4/file.txt (Permission denied)

I have added the following permissions to my manifest:

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

I am also requesting permission at runtime. I have also downgraded from SDK 30 to SDK 28 and also tried adding the following to manifest file:

 android:requestLegacyExternalStorage="true"

I don't understand what I am doing wrong, but I am still unable to write to secondary external storage (SD Card).


Solution

  • Removable micro SD cards are not writable since Android Kitkat.

    Except for one app specific directory.