Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SD card directory folders name list

How can I get names of all folders (not files) in specific directory on SD card? For example all subfolders names in /sdcard/first_level_folder/....

I need folder name, so I can pass complete path (string) to the method which will then compress (zip) it.

Thanks.

like image 491
waxi Avatar asked Aug 02 '11 19:08

waxi


1 Answers

I think what you are looking for is

File dir = new File("directoryPath");
FileFilter fileFilter = new FileFilter() {
    public boolean accept(File file) {
        return file.isDirectory();
    }
};
File[] files = dir.listFiles(fileFilter);
like image 83
Justin Breitfeller Avatar answered Sep 30 '22 18:09

Justin Breitfeller