android mkdirs not working

Did you put

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

in your AndroidManifest? If you are using android M you must request user permission to write on sd, look here an example


Some one like me who was trying in Android10. Please use below API in manifest:

<application android:requestLegacyExternalStorage="true" ... >
    ...
  </application> 

Latest Update From Google: After you update your app to target Android 11, the system ignores the requestLegacyExternalStorage flag.


For those not as experienced like me. I fought this issue, lost hair for some time. I am targeting api 21 (for compatibility sake) and it worked on lollipop but on marshmallow it would not create the directory. I did have the "uses" permission in the manifest but it still would not work. Apparently in Marshmallow when you install with Android studio it never asks you if you should give it permission it just quietly fails, like you denied it. You must go into Settings, apps, select your application and flip the permission switch on.


IDIOT ME! i have used the Manifest Permission but when installed the app on phone i didnt grant permission for storage!... i understand a negative on this question... but i hope if someone else face the same..check your phone permission. sorry all for inconvenience.

Tags:

Android

Mkdirs