List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:Main.java
public static long getAvailableExternalMemorySize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
public static String getAvailableExternalMemorySize(Context context) { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(context, availableBlocks * blockSize); } else {/*w w w . java2s . co m*/ return "ERROR"; } }
From source file:Main.java
public static long getSdAvailaleSize() { if (!isSdCardExist()) { return 0; }/* w ww. java 2s .com*/ StatFs stat = new StatFs(getSDPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
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 long[] getRomMemroy() { long[] romInfo = new long[2]; //Total rom memory romInfo[0] = getTotalInternalMemorySize(); //Available rom memory File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); romInfo[1] = blockSize * availableBlocks; return romInfo; }
From source file:Main.java
public static long getAvailaleSDCardSize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); long asize = availableBlocks * blockSize; LOG("getAvailaleSDCardSize asize: " + asize); return asize; }
From source file:Main.java
/** * Check how much usable space is available at a given path. * * @param path The path to check//w w w.j ava 2s. c o m * * @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 float getLocalStorageSpace() { float space = 0; try {/*from w w w. j a v a 2 s . 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
/** * Check how much usable space is available at a given path. * * @param path The path to check/* w w w. j a v a 2 s . c om*/ * @return The space available in bytes */ @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(); }
From source file:Main.java
public static long getFreeDiskSpace() { String status = Environment.getExternalStorageState(); long freeSpace = 0; if (status.equals(Environment.MEDIA_MOUNTED)) { try {//from w w w . j av a2 s . c o m File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); freeSpace = availableBlocks * blockSize / 1024; } catch (Exception e) { e.printStackTrace(); } } else { return -1; } return (freeSpace); }