Here you can find the source of getAvailableStorageSize(File dir)
public static long getAvailableStorageSize(File dir)
//package com.java2s; import android.os.StatFs; import java.io.*; public class Main { public static long getAvailableStorageSize(File dir) { long size = -1; if (dir != null && dir.exists() && dir.isDirectory()) { try { StatFs stat = new StatFs(dir.getPath()); size = (long) stat.getBlockSize() * stat.getAvailableBlocks(); } catch (Exception e) { e.printStackTrace();/* ww w . j a v a 2s . co m*/ } } return size; } }