-1

I need to access all files inside a folder which is inside the downloads folder.

I can get the files in the downloads folder like this Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) and that return a File.

How do I get the same but for the folder mCustomFolder?

Simson
  • 3,373
  • 2
  • 24
  • 38
Tsabary
  • 3,119
  • 2
  • 24
  • 66

2 Answers2

0

It should be simple I guess. Try this.

File file = new File(Environment.getExternalStorageDirectory().getPath()+"/someFolder");

for(File f : files){
   //access your all files and folders here inside the given folder

}

Learn more about here on how to access external storage.

vikas kumar
  • 10,447
  • 2
  • 46
  • 52
0

This is how I would do it:

File subDir = new File(
    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
    "/mCustomFolder/");
File[] files = subDir.listFiles();
for (File f : files) {
    // f is your file
}
user1506104
  • 6,554
  • 4
  • 71
  • 89