Home>

Hello! I have a folder SR_DATA. in which the subfolders lie, in each of the 20 files. There are also files in SR_DATA. The question is this: how to get a list of files from the folder and its subfolders?

Recursively run folders. What is the problem?

Suvitruf - Andrei Apanasik2021-05-06 07:14:08

The fact is that I do not know how to do it)

Helisia2021-05-06 07:14:08

@SuperCreePer files in InternalStorage or External? Or in Assets?

Suvitruf - Andrei Apanasik2021-05-06 07:14:08

@woes, please add it as an answer.

Helisia2021-05-06 07:14:08
  • Answer # 1

    The fact is that I do not know how to do it)

    then see one of the first commercial implementation options:

    Public ArrayList <
    File >
     ListFilesWithSubfolders (File Dir) {
        ARRAYLIST <
    File >
     Files= New ArrayList <
    File >
    ();
        For (File File: dir.listfiles ()) {
            if (file.isdirectory ())
                Files.addall (ListFilesWithSubfolders (File));
            ELSE.
                Files.add (File);
        }
        RETURN FILES;
    }
    

    @woes, thank you very much!

    Helisia2021-05-06 07:14:08