7

In my application I want to display all folders on an SD card in a listview and need functionality such that if a user clicks on a folder it will show its sub-directories.

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
Saurabh
  • 350
  • 2
  • 10

1 Answers1

11
File f = new File(path);
File[] files = f.listFiles();
for (File inFile : files) {
    if (inFile.isDirectory()) {
        // is directory
    }
}

This will return you the list of folders in your path. From here: https://stackoverflow.com/a/6997422/2065418

Community
  • 1
  • 1
Damien R.
  • 3,383
  • 1
  • 21
  • 32