Java tutorial
//package com.java2s; import android.text.TextUtils; import java.io.File; public class Main { public static long getFileSize(String path) throws Throwable { if (TextUtils.isEmpty(path)) { return 0L; } else { File file = new File(path); return getFileSize(file); } } public static long getFileSize(File file) throws Throwable { if (!file.exists()) { return 0L; } else if (!file.isDirectory()) { return file.length(); } else { String[] names = file.list(); int size = 0; for (int i = 0; i < names.length; ++i) { File f = new File(file, names[i]); size = (int) ((long) size + getFileSize(f)); } return (long) size; } } }