Iterate through the specified directory in Android

I am trying to develop a security application on Android, and I want to iterate over the file names of a specific directory so that I can compare the hash value of each file in the directory.

I already learned how to do hashing, but for the iterative part, I got confused about how it works.

+7
source share
1 answer

Do you want you to go through directories recursively?

Something like that:

public void traverse (File dir) { if (dir.exists()) { File[] files = dir.listFiles(); for (int i = 0; i < files.length; ++i) { File file = files[i]; if (file.isDirectory()) { traverse(file); } else { // do something here with the file } } } } 
+21
source

All Articles