How do I check if a directory exist on the sdcard in android?
Use the Function like: String dir_path = Environment. getExternalStorageDirectory() + "//mydirectory//"; if (! dir_exists(dir_path)){ File directory = new File(dir_path); directory.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With