0

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.

drum
  • 5,416
  • 7
  • 57
  • 91

1 Answers1

1

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);
    }
}
Community
  • 1
  • 1
Jon O
  • 6,532
  • 1
  • 46
  • 57
  • Thank you! Some times when I read the documentation, I don't really understand its usage. I guess this is one of the cases. – drum Apr 03 '12 at 02:24