List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:Main.java
public static long getAvailableSize(String path) { try {//from www . j a v a 2s . co m File base = new File(path); StatFs stat = new StatFs(base.getPath()); long nAvailableCount = stat.getBlockSize() * ((long) stat.getAvailableBlocks()); return nAvailableCount; } catch (Exception e) { e.printStackTrace(); } return 0; }
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. c o m*/ return 0; }
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
/** * Get the left size of the SDCard in Bytes. * //from w ww . j av a 2s . c om * @return the left size */ @SuppressWarnings("deprecation") public static long getSDCardLeftSize() { File sdcard = Environment.getExternalStorageDirectory(); if (sdcard.exists()) { StatFs statFs = new StatFs(sdcard.getAbsolutePath()); long blockSize = statFs.getBlockSize(); long availableBlocks = statFs.getAvailableBlocks(); return blockSize * availableBlocks; } return 0; }
From source file:Main.java
public static long getSdCardFree() { long l = 0L;// ww w. ja v a 2s .c o m if (Environment.getExternalStorageState().equals("mounted")) { StatFs statfs = new StatFs(Environment.getExternalStorageDirectory().getPath()); l = ((long) statfs.getBlockSize() * (long) statfs.getAvailableBlocks()) / 1024L / 1024L; } return l; }
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
/** * @return Available external memory// www . ja v a 2s .co m */ public static int getAvailableExternalMemorySize() { if (isExternalStorageAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); int blockSize = stat.getBlockSize(); int availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; } else { return 0; } }
From source file:Main.java
public static boolean checkStorageSpace() { StatFs stat = new StatFs(Environment.getDataDirectory().getAbsolutePath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); if (blockSize * availableBlocks / 1024 / 1024 >= 128) { return true; }/* ww w.ja v a 2 s . c o m*/ return false; }
From source file:Main.java
/** * @return The total storage in MegaBytes */// w ww .jav a 2 s. co m public static Long getTotalInternalDataSize() { StatFs stat = new StatFs(Environment.getDataDirectory().getPath()); long size = stat.getBlockCount() * stat.getBlockSize(); return size / BYTES_TO_MB; }
From source file:Main.java
private static long getTotalSize(String path) { StatFs fileStats = new StatFs(path); fileStats.restat(path);//w w w . j av a 2 s . co m return (long) fileStats.getBlockCount() * fileStats.getBlockSize(); }