Android获得文件夹大小

       /**
	 * 获取文件夹大小 
	 * @author YOLANDA
	 * @param path
	 * @return
	 */
	public static long getFileAllSize(String path) {
		File file = new File(path);
		if (file.exists()) {
			if (file.isDirectory()) {
				File[] children = file.listFiles();
				long size = 0;
				for (File f : children)
					size += getFileAllSize(f.getPath());
				return size;
			} else {
				long size = file.length();
				return size;
			}
		} else {
			return 0;
		}
	}

你可能感兴趣的:(Android获得目录大小)