i am trying to develop a security application on Android and i want to iterate through the filenames of a specific directory so that i can compare the hash value of each file in the directory.
I have already found out how to do the hashing but for the iterating part i am confused on how it works.
You mean you want to traverse a directory recursively?
Something like this:
public void traverse (File dir) {
if (dir.exists()) {
File[] files = dir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; ++i) {
File file = files[i];
if (file.isDirectory()) {
traverse(file);
} else {
// do something here with the file
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With