I am working on a task to read SD card files and I am showing a progress bar with calculated percentage based on SD card files like some antivirus software in Android. I don’t know how to implement this functionality. My SD card read files code shown below:
File root = new File (Environment.getExternalStorageDirectory().getAbsolutePath());
scan(root);
Scan function code shown below:
public void scan (File path) {
for (File f : path.listFiles()) {
if (f.isFile()) {
Toast.makeText(getApplicationContext(),f.getAbsoluteFile().toString(),Toast.LENGTH_SHORT).show();
}
else {
}
}
}
Can you show me how to do this?
I guess that a file list has a length. You can use this length in your loop to compute a percentage of number of files completed so far. Perhaps something like: