1

I am developer and I want list All folders in path in file manager but show all files and folders in method file.list() please help me to show all folders not files in path.

   File file = new File("Path");

    if(file.exists() && file.canRead()) {
        String[] list = file.list();
        int len = list.length;

        /* add files/folder to arraylist depending on hidden status */
        for (int i = 0; i < len; i++) {
        if(list[i].toString().charAt(0) != '.')
            mDirContent.add(list[i]);
    }
}
Mir Hussain
  • 478
  • 2
  • 15

1 Answers1

1

What's about this android, how to get directory listing?

Shortly, you need to use File.listFiles() method and then check if an item is a directory by method File.isDirectory().

Community
  • 1
  • 1
Yev Kanivets
  • 1,780
  • 3
  • 22
  • 38