Exception 'open failed: EACCES (Permission denied)' on Android

前端 未结 30 1420
[愿得一人]
[愿得一人] 2020-11-22 00:59

I am getting

open failed: EACCES (Permission denied)

on the line OutputStream myOutput = new FileOutputStream

相关标签:
30条回答
  • 2020-11-22 01:31

    keep in mind that even if you set all the correct permissions in the manifest: The only place 3rd party apps are allowed to write on your external card are "their own directories" (i.e. /sdcard/Android/data/) trying to write to anywhere else: you will get exception: EACCES (Permission denied)

    0 讨论(0)
  • 2020-11-22 01:32

    The post 6.0 enforcement of storage permissions can be bypassed if you have a rooted device via these adb commands:

    root@msm8996:/ # getenforce
    getenforce
    Enforcing
    root@msm8996:/ # setenforce 0
    setenforce 0
    root@msm8996:/ # getenforce
    getenforce
    Permissive
    
    0 讨论(0)
  • 2020-11-22 01:33

    Solution for Android Q:

    <application ...
        android:requestLegacyExternalStorage="true" ... >
    
    0 讨论(0)
  • 2020-11-22 01:33

    I had the same error when was trying to write an image in DCIM/camera folder on Galaxy S5 (android 6.0.1) and I figured out that only this folder is restricted. I simply could write into DCIM/any folder but not in camera. This should be brand based restriction/customization.

    0 讨论(0)
  • 2020-11-22 01:34
    Environment.getExternalStoragePublicDirectory();
    

    When using this deprecated method from Android 29 onwards you will receive the same error:

    java.io.FileNotFoundException: open failed: EACCES (Permission denied)

    Resolution here:

    getExternalStoragePublicDirectory deprecated in Android Q

    0 讨论(0)
  • 2020-11-22 01:35

    In addition to all the answers, make sure you're not using your phone as a USB storage.

    I was having the same problem on HTC Sensation on USB storage mode enabled. I can still debug/run the app, but I can't save to external storage.

    0 讨论(0)
提交回复
热议问题