drum
drum

Reputation: 5661

How to retrieve every file in the Internal Storage?

In Android, assuming that I have files in "/data/data/package.name/", without knowing the names or how many files exist, what is the best way to retrieve/iterate them all? Also, the name is numerical only.

Upvotes: 0

Views: 142

Answers (1)

Jon O
Jon O

Reputation: 6591

It looks like you want to list all of the files in the directory, and (possibly) recurse if a file is a directory.

You can find how to do this at the answer to this question.

Copy-pasted:

File f = new File("/data/data/package.name/");
File[] files = f.listFiles();
for (File inFile : files) {
    if (inFile.isDirectory()) {
        // is directory; recurse?
    } else {
        doLogicFor(inFile);
    }
}

Upvotes: 1

Related Questions