0

I got this error when running my app on android 13 and above devices

 java.io.FileNotFoundException: /storage/emulated/0/Download/MyTest.apk: open failed: EACCES (Permission denied)

In source code exception thrown in bellow code line. apk file is already created in this location (i have checked with path)

 FileOutputStream fos = new FileOutputStream(apkFile);

have tried with bellow mentioned permission list

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACTION_OPEN_DOCUMENT_TREE " />
    <uses-permission android:name="android.permission.ACTION_OPEN_DOCUMENT " />
    <uses-permission android:name="android.permission.ACTION_CREATE_DOCUMENT " />
    <uses-permission android:name="android.permission.READ_MEDIA_* " />
    <uses-permission android:name="android.permission.WRITE_MEDIA_* " />
    <uses-permission android:name="android.permission.READ_MEDIA_FILES* " />
    <uses-permission android:name="android.permission.WRITE_MEDIA_FILES* " />

but those permission only granted foe audio,video and photos how can we access any file in android 13 and above ? and also it's working fine on android 11 as well

  • Try to move MyTest.apk from `Downloads` to another directory (`DCIM`, `Movie` etc) and then try to access it from the App. Let me know if it working or not. – M DEV Jun 14 '23 at 11:09
  • Try to apply for permissions MANAGE_EXTERNAL_STORAGE dynamically, or check whether the corresponding storage permissions in the settings are turned on – Matrix Jun 14 '23 at 11:57
  • @M Dev java.io.FileNotFoundException: /storage/emulated/0/DCIM/MyTest.apk: open failed: EPERM (Operation not permitted) – Chamin Thilakarathne Jun 14 '23 at 12:21

0 Answers0