Check if directory exist on android's sdcard Check if directory exist on android's sdcard android android

Check if directory exist on android's sdcard


Regular Java file IO:

File f = new File(Environment.getExternalStorageDirectory() + "/somedir");if(f.isDirectory()) {   ....

Might also want to check f.exists(), because if it exists, and isDirectory() returns false, you'll have a problem. There's also isReadable()...

Check here for more methods you might find useful.


File dir = new File(Environment.getExternalStorageDirectory() + "/mydirectory");if(dir.exists() && dir.isDirectory()) {    // do something here}


The following code also works for java files:

// Create file upload directory if it doesn't exist    if (!sdcarddir.exists())   sdcarddir.mkdir();