Android 5(HTC) EACCES (Permission denied)

1.2k views Asked by At

app can't create folder/file on android 5(HTC HTC6525LVW os version: 5.0.1) external storage in directory owned by app.

Parent folder is returned by [getExternalFilesDirs(String type)][1] method.

Sdcard is mounted.

Anyone else having this problem or suggestion how to solve it?

(Unfortunately I don't have this device to test it more)

Edit: From one user I know that prior this bug she encrypted sdcard and then formatted it.

2

There are 2 answers

2
d0nut On

Some potential ideas as to what caused it:

  1. If the phone is running in USB Storage mode when connected to your computer you can still deploy/debug like normal but write operations will fail

  2. You were missing a permission: in your manifest file you should check to see if you have <permission name=”android.permission.WRITE_EXTERNAL_STORAGE” >

  3. Permissions in the wrong location: make sure that your permission tag (in manifest) is located outside of the application

  4. Writing to the data folder can cause issues like this so make sure you're writing to sdcard and not data

This is everything I could think of. Hope it helps :)

2
Arun On

Add permission to your manifest.xml file permissions

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