Android: mkdirs()/mkdir() on external storage returns false Android: mkdirs()/mkdir() on external storage returns false android android

Android: mkdirs()/mkdir() on external storage returns false


I got the same problem,and I am sure I had put the permission tag in the right place,but mkdirs didn't work yet, my system is Android 6.0, I resolve it now , you can check as below:

  1. make sure your put the permission tag in .
  2. open "setting/application" in your phone,check your application's permission(I found the permission in my manifest statement is not here),open the switch of the permission like this.(I found it is closed in default which make "mkdirs" failed)

enter image description here


I have had the same problem and I have searched everything for a week trying to find the answer. I think I found it and I think it's ridiculously easy, you have to put the uses-permission statement in the right place...

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.company.name"     android:versionCode="1"    android:versionName="0.2">    <uses-sdk android:minSdkVersion="8" />    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

When I had it inside the <application></application> section it did not work.


I know this is an old post but perhaps my answer can help somebody.

After several days dealing with this problem I have realized that while the phone is connected to the PC, which it turns to be always during development, the SD card is not available. Thus making to fail any attempt to create a directory or file over it.To make it "easier" it seemed to behave differently depending of the telephone under test.

I know it can sound quite a silly problem, but it cost a lot of time that maybe some other can save.