Java tutorial
//package com.java2s; import android.os.Build; import android.os.StatFs; import java.io.File; public class Main { /** * Gets the free disk space at the specified location. * * @param dir * the directory linking to the filesystem to query * @return the free disk space at {@code dir} in bytes */ private static long getFreeDiskSpace(File dir) { StatFs statFs = new StatFs(dir.getAbsolutePath()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { return statFs.getBlockCountLong() * statFs.getBlockSizeLong(); } else { //noinspection deprecation return statFs.getBlockCount() * statFs.getBlockSize(); } } }