List of usage examples for android.os StatFs getAvailableBlocks
@Deprecated public int getAvailableBlocks()
From source file:Main.java
public static long computeFreeSpace() { File dataDir = Environment.getDataDirectory(); StatFs stat = new StatFs(dataDir.getPath()); return stat.getAvailableBlocks() * stat.getBlockSize(); }
From source file:Main.java
public static long getExternalStorageFreeSpace() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); return stat.getAvailableBlocks() * stat.getBlockSize(); }
From source file:Main.java
public static long getSDCardAvailableCount() { StatFs statfs = new StatFs(SDCARD_PATH); return ((long) statfs.getAvailableBlocks()) * statfs.getBlockSize(); }
From source file:Main.java
public static float getLocalStorageSpace() { float space = 0; try {//from w w w .j ava 2s . c o m StatFs stat = new StatFs("/data/"); space = stat.getAvailableBlocks() * (float) stat.getBlockSize(); } catch (Exception e) { e.printStackTrace(); } return space; }
From source file:Main.java
public static long getAvailableMb(String path) { final long SIZE_KB = 1024L; final long SIZE_MB = SIZE_KB * SIZE_KB; long availableSpace = -1L; StatFs stat = new StatFs(path); availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize(); return availableSpace / SIZE_MB; }
From source file:Main.java
private static float calculateSizeInMB(StatFs stat) { if (stat != null) { return stat.getAvailableBlocks() * (stat.getBlockSize() / (1024f * 1024f)); }/*from w w w . jav a 2 s .co m*/ return 0; }
From source file:Main.java
public static long getPathSpace(String path) { StatFs statFs = new StatFs(path); return statFs.getBlockSize() * (long) statFs.getAvailableBlocks(); }
From source file:Main.java
public static boolean isDirectoryValid(String path) { File file = new File(path); if (!file.canWrite()) { return false; }// w w w . j a v a 2 s . c om StatFs sf = new StatFs(file.getPath()); long availCount = sf.getAvailableBlocks(); if (availCount > 0) { return true; } return false; }
From source file:Main.java
public static int getFreeMemory(String path) { StatFs statFs = new StatFs(path); int free = (statFs.getAvailableBlocks() * statFs.getBlockSize()); return Math.abs(free); }
From source file:Main.java
public static long getAvailableStorage() { try {/*from w w w .ja va 2 s . c o m*/ String storageDirectory = Environment.getExternalStorageDirectory().toString(); StatFs stat = new StatFs(storageDirectory); return (long) stat.getAvailableBlocks() * (long) stat.getBlockSize(); } catch (Exception e) { // if we can't stat the filesystem then we don't know how many // pictures are remaining. it might be zero but just leave it // blank since we really don't know. return 0; } }