When starting my android application, I need to create a directory on the sd card, for a small number of users this fails and I can't figure out the reason for it...
(I've found similar problems caused by the WRITE_EXTERNAL_STORAGE permission missing, it's there and it works for almost all users so I don't think this is reason)
I've simplified the previous situation to make it easier to explain, if creating a directoy fails, I run a test case where I try to make a .test directory on the sdcard:
new File(Environment.getExternalStorageDirectory(), ".test").mkdir() -> false
new File(Environment.getExternalStorageDirectory(), ".test").mkdirs() -> false
File properties of the relevant directories:
/sdcard/.test (exists=false canWrite=false canRead=false canExecute=err isDirectory=false isFile=false)
/sdcard (exists=true canWrite=true canRead=true canExecute=err isDirectory=true isFile=false)
/ (exists=true canWrite=false canRead=true canExecute=err isDirectory=true isFile=false)
getExternalStorageState=mounted
(canExecute returns err because the test is run on sdk < 9)
Suggestions and ideas are very welcome...
It is common when you don't have a permission in your manifest.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
As for me it was the only wrong thing.