16

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.

Martin Vandzura
  • 3,047
  • 1
  • 31
  • 63
  • You should try this again with a phone that's not the HTC with the **exact** same configuration (same USB debugging mode, same installation process, etc.) and see if it's just an android thing or if it's an HTC thing. – d0nut Jun 25 '15 at 13:01
  • Are you trying to create folder/file from a class from the same package as the class that called `getExternalFilesDirs(String)`? – dragi Jun 30 '15 at 12:35
  • @helleye yes, same package – Martin Vandzura Jun 30 '15 at 12:41
  • Have you tried to run on another device with v5.0.1? In general, on which devices and Android versions have you successfully(and not) run your app? – dragi Jun 30 '15 at 13:30
  • @helleye problem is only on device specified in my question. – Martin Vandzura Jun 30 '15 at 13:37

2 Answers2

9

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 :)

d0nut
  • 2,835
  • 1
  • 18
  • 23
0

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" />
Arun
  • 1,177
  • 9
  • 15