Search code examples
androidstorageandroid-external-storageandroid-storage

How do I access a "child" folder under a file?


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?


Solution

  • 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.