I have
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in my manifest file, however I fail when trying to create a directory
Log.d(LOG_STRING, android.os.Environment.getExternalStorageState() );
java.io.File folder = new java.io.File(Environment.getExternalStorageDirectory() + java.io.File.separator + "test");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
Log.d(LOG_STRING, "Created directory");
} else {
Log.d(LOG_STRING, "FAILED WHILE CREATING DIRECTORY");
}
The status of external storage is "mounted", but the test
directory cannot be created and the output is "FAILED WHILE CREATING DIRECTORY"
.
Browsing in the phone to the "App Info", the permission "modify or delete the contents of your USB storage" is marked to be activated for my application.
What could be the cause of this? Some special setting of the phone? It's a Samsung GT-I9506 with Android 4.3 (API18). To be noted is that the getExternalStorageDirectory
is not on the SD card, but on the internal storage (/storage/emulated/0/
).
Update:
Speaking with colleagues, it seems that this device has undergone several tweaking after having been rooted (to allow a specific application to directly write on the SD card). It's probably not worth to investigate further, I will simply switch to another device. I'll keep the device for a while and if anybody will show up with an answer I will quickly test if it solves the problem.
Update 2: (Bounty end)
The problem remains unsolved, but as stated before, it is most likely something very specific to this one device. It's not possible to write on any path, being it external or internal storage, not even in the path returned by getExternalCacheDir()
.