Code example for StatFs

Methods: getAvailableBlocks, getBlockSize

0
    @SuppressLint("NewApi") 
    public static long getUsableSpace(File path) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            return path.getUsableSpace();
        } 
        final StatFs stats = new StatFs(path.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } 
 
    /** 
     * Get the memory class of this device (approx. per-app memory limit) 
     *  
     * @param context 
     * @return 
     */ 
    public static int getMemoryClass(Context context) {
        return ((ActivityManager) context.getSystemService(
                Context.ACTIVITY_SERVICE)).getMemoryClass();
    } 
 
    /**