List of usage examples for android.os StatFs getAvailableBlocks
@Deprecated public int getAvailableBlocks()
From source file:Main.java
public static long getSDSize() { String str = Environment.getExternalStorageDirectory().getPath(); StatFs localStatFs = new StatFs(str); long blockSize = localStatFs.getBlockSize(); return localStatFs.getAvailableBlocks() * blockSize; }
From source file:Main.java
/** * Check if has enough space for record//from w w w . jav a 2 s .c o m * * @param recordingSdcard The recording sdcard path * * @return true if has enough space for record */ public static boolean hasEnoughSpace(String recordingSdcard) { boolean ret = false; try { StatFs fs = new StatFs(recordingSdcard); long blocks = fs.getAvailableBlocks(); long blockSize = fs.getBlockSize(); long spaceLeft = blocks * blockSize; ret = spaceLeft > LOW_SPACE_THRESHOLD ? true : false; } catch (IllegalArgumentException e) { Log.e(TAG, "hasEnoughSpace, sdcard may be unmounted:" + recordingSdcard); } return ret; }
From source file:Main.java
@SuppressLint("NewApi") public static final long getUsableSpace(String accountName) { File savePath = Environment.getExternalStorageDirectory(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) { return savePath.getUsableSpace(); } else {// w ww . j av a2 s. c o m StatFs stats = new StatFs(savePath.getAbsolutePath()); return stats.getAvailableBlocks() * stats.getBlockSize(); } }
From source file:Main.java
public static long freeSpaceOnSd() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long sdFreeMB = (long) stat.getAvailableBlocks() * stat.getBlockSize(); return sdFreeMB; }
From source file:Main.java
public static long getUsableSpace(File path) { final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:Main.java
public static long getSDCardAvailableAtKB() { StatFs sfs = new StatFs(Environment.getExternalStorageDirectory().getPath()); long availableCount = sfs.getAvailableBlocks(); long blockSizea = sfs.getBlockSize(); return (availableCount * blockSizea) / 1024; }
From source file:Main.java
/** * Check how much usable space is available at a given path. * //from w ww. j a v a 2 s . c om * @param path * The path to check * @return The space available in bytes */ 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(); }
From source file:Main.java
public static long getAvailableSpace(File dir) { try {//from w w w . j ava2 s . co m final StatFs stats = new StatFs(dir.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } catch (Throwable e) { Log.e("getAvailableSpace", e.getMessage(), e); return -1; } }
From source file:Main.java
public static int freeSpaceOnSd() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()) / MB; return (int) sdFreeMB; }
From source file:Main.java
public static long getFreeSpaceOnDevice() { StatFs localStatFs = new StatFs(Environment.getDataDirectory().getPath()); return localStatFs.getBlockSize() * localStatFs.getAvailableBlocks(); }