How can I get the size of a folder on SD card in Android?
Is it possible to easily get the size of a folder on the SD card? I use a folder for caching of images, and would like to present the total size of all cached images. Is there a way to this other than iterating over each file? They all reside inside the same folder? Moss Just go through all files and sum the length of them: /** * Return the size of a directory in bytes */ private static long dirSize(File dir) { if (dir.exists()) { long result = 0; File[] fileList = dir.listFiles(); for(int i = 0; i < fileList.length; i++) { // Recursive call if it's a directory if(fileList[i].isDirectory()) {