Read internal files inside a particular folder in Android
android, file
Solution
To read the files inside your device you would do something like this:
// gets the files in the directory
File fileDirectory = new File(Environment.getDataDirectory()+"/YourDirectory/");
// lists all the files into an array
File[] dirFiles = fileDirectory.listFiles();
if (dirFiles.length != 0) {
// loops through the array of files, outputing the name to console
for (int ii = 0; ii < dirFiles.length; ii++) {
String fileOutput = dirFiles[ii].toString();
System.out.println(fileOutput);
}
}
If you wanted to get the files off an SD card, you would simply change `getDataDirectory` to `getExternalStorageDirectory`.
Problem
Surely, this ins't a very hard question to be answered, but I'm having some trouble to implement this. My issue is: I need to read (or list) the files inside of a particular folder (say "myFolder", located in internal storage root) in Android's internal storage. Sure, it is possible, but how to do this? Thanks in advance!