3 step:
-
To get sd card is mounted at
/sdcard
or any other location by using this way:Environment.getExternalStorageDirectory();
-
You have to take uses-permission entry in the AndroidManifest.xml file:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-
If directory already exists, then mkdir return false. Try creatinng new directory if it not exist:
File folder = new File(Environment.getExternalStorageDirectory() + "/map"); boolean success = true; if (!folder.exists()) { success = folder.mkdir(); } if (success) { // Do something on success } else { // Do something else on failure }
6
solved Android java : How to create folder inside android devices?