I want to create a directory on "/mnt/extsd/MyFolder" this path. while calling mkdir() it returns false.I inserted the sdcard on my tablet, got the external path as "/mnt/extsd" and trying to create a folder on this path. Below is my code,
File lSDCardDirFile = new File("/mnt/extsd/MyFolder");
if (!lSDCardDirFile.exists()) {
System.out.println("Is folder created --- " + lSDCardDirFile.mkdirs());
}
I gave the permissions, . I want to create the folder in External sd card which is removable sd card. I am using android 4.0 ICS version device.
I created a different method for getting paths fom external SD card,
public static String[] getStorageDirectories()
{
String[] lDirs = null;
BufferedReader lBufferReader = null;
try {
lBufferReader = new BufferedReader(new FileReader("/proc/mounts"));
ArrayList list = new ArrayList();
String lStrline;
while ((lStrline = lBufferReader.readLine()) != null) {
if (lStrline.contains("vfat") || lStrline.contains("/mnt")) {
StringTokenizer lTokenizer = new StringTokenizer(lStrline, " ");
String lStrPath = lTokenizer.nextToken();
lStrPath = lTokenizer.nextToken(); // Take the second token, i.e. mount point
if (lStrPath.equals(Environment.getExternalStorageDirectory().getPath())) {
list.add(lStrPath);
}
else if (lStrline.contains("/dev/block/vold")) {
if (!lStrline.contains("/mnt/secure") && !lStrline.contains("/mnt/asec") && !lStrline.contains("/mnt/obb") && !lStrline.contains("/dev/mapper") && !lStrline.contains("tmpfs")) {
list.add(lStrPath);
}
}
}
}
lDirs = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
lDirs[i] = (String) list.get(i);
}
}
catch (FileNotFoundException e) {}
catch (IOException e) {}
finally {
if (lBufferReader != null) {
try {
lBufferReader.close();
} catch (IOException e) {
}
}
}
return lDirs;
}`
From this method I got the path, but while trying to create a directory, the mkdir() returns false.