List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:Main.java
public static long getTotalExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; } else {//from w ww .j ava 2 s. co m return -1; } }
From source file:Main.java
public static long getAvailableExternalMemorySize() throws IllegalArgumentException { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; } else {/*from ww w.j a va2s. c o m*/ return -1; } }
From source file:Main.java
/** * @return Total internal memory/*from ww w . j ava 2 s . c o m*/ */ public static int getTotalInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); int blockSize = stat.getBlockSize(); int totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; }
From source file:Main.java
/** * @return Available internal memory/*from ww w .java2s . c o m*/ */ public static int getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); int blockSize = stat.getBlockSize(); int availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
@SuppressWarnings("deprecation") public static long getTotalExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; } else {/*from ww w. j a v a 2 s. co m*/ return -1; } }
From source file:Main.java
@SuppressWarnings("deprecation") public static long getAvailableExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; } else {/*from ww w . j av a 2s. c o m*/ return -1; } }
From source file:Main.java
/** * Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM.//from w w w.java2 s. c o m * * @return Number of bytes available. */ public static long getAvailableInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = stat.getBlockSize(); final long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
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
/** * Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM.//www .ja v a2s. co m * * @return Total number of bytes. */ public static long getTotalInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = stat.getBlockSize(); final long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; }
From source file:Main.java
public static String getTotalExternalMemorySize(Context context) { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return Formatter.formatFileSize(context, totalBlocks * blockSize); } else {/*w ww . j ava2 s . c o m*/ return "ERROR"; } }