I got a problem with the following code:
File folder = new File(Environment.getExternalStorageDirectory() + "/myapp/folderone/foldertwo");
boolean success = false;
if (!folder.exists()) {
success = folder.mkdir();
}
if (!success) {
} else {
}
but its simply not working I also added the permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Hope someone could help me with this.
Try to use mkdirs()
instead of mkdir()
only, this worked for me.
Example:
File folder = new File(Environment.getExternalStorageDirectory() + "/myapp/folderone/foldertwo");
boolean success = false;
if (!folder.exists()) {
success = folder.mkdirs();
}
if (!success) {
} else {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With