Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if directory exist on android's sdcard

How do I check if a directory exist on the sdcard in android?

like image 272
Alxandr Avatar asked Apr 12 '10 21:04

Alxandr


People also ask

How to Check folder exist in Android?

Use the Function like: String dir_path = Environment. getExternalStorageDirectory() + "//mydirectory//"; if (! dir_exists(dir_path)){ File directory = new File(dir_path); directory.

What is a directory in Android?

A Directory represents a contacts corpus, e.g. Local contacts, Google Apps Global Address List or Corporate Global Address List. A Directory is implemented as a content provider with its unique authority and the same API as the main Contacts Provider.


1 Answers

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.

like image 170
synic Avatar answered Nov 12 '22 18:11

synic