In my app, I want to find the size of many directories and I need it run fast. I have seen these methods, two of which are not fast enough and the third is just for Java, not Android.
First:
public static long folderSize(File directory) {
long length = 0;
for (File file : directory.listFiles()) {
if (file.isFile())
length += file.length();
else
length += folderSize(file);
}
return length;
}
Second:
Third:
Using Java 7 nio api, which doesn't work in android
What other fast and efficient way is there to be used?