List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:Main.java
static public long getFreeSpaceOnSD() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); return stat.getAvailableBlocks() * stat.getBlockSize(); }
From source file:Main.java
public static long getAvailableStorage() { try {//ww w . j a va 2 s.c om 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; } }
From source file:Main.java
public static long getFreeSpace(String dir) { StatFs state = null; try {//w w w . j a va2s . c o m state = new StatFs(dir); long blockSize = state.getBlockSize(); long availableCount = state.getAvailableBlocks(); long free = availableCount * blockSize; if (free > 0) { return free; } } catch (Exception e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static long getUsableSpace(File path) { final StatFs stats = new StatFs(Environment.getExternalStorageDirectory().getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:Main.java
/** * @return Free size in SDcard//from w w w .j a v a 2 s . c o m */ private static int sdFreeSize() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks(); int sdFreeMegs = (int) (bytesAvailable / (1024 * 1024)); return sdFreeMegs; }
From source file:Main.java
/** * @return The available storage in MegaBytes *//* w w w . ja va 2 s . c o m*/ public static Long getAvailableInternalDataSize() { StatFs stat = new StatFs(Environment.getDataDirectory().getPath()); long size = stat.getAvailableBlocks() * stat.getBlockSize(); return size / BYTES_TO_MB; }
From source file:Main.java
public static String getStorageSize(Context context) { StatFs stat = new StatFs(Environment.getDataDirectory().getPath()); return Formatter.formatFileSize(context, ((long) stat.getBlockSize()) * ((long) stat.getBlockCount())); }
From source file:Main.java
public static long getSDAllSize() { StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath()); return ((((long) sf.getBlockCount()) * ((long) sf.getBlockSize())) / 1024) / 1024; }
From source file:Main.java
public static int freeSpaceOnSd() { StatFs stat = new StatFs(getSDPath()); double sdFree = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()); return (int) sdFree; }
From source file:Main.java
/** * Returns the total number of bytes of external storage. * @return Bytes of external storage in total, or -1 if no SD card mounted. *//*from w ww.j a va2 s.c o m*/ static public long getTotalExternalMemorySize() { if (isSDCardMounted()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; } else { return -1; } }