List of usage examples for android.os StatFs getBlockCount
@Deprecated public int getBlockCount()
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device disk space. */// w ww . ja v a 2s. com static String getDiskCurrent() { if (android.os.Build.VERSION.SDK_INT < 18) { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCount() * statFs.getBlockSize()); long free = (statFs.getAvailableBlocks() * statFs.getBlockSize()); return Long.toString((total - free) / 1048576L); } else { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCountLong() * statFs.getBlockSizeLong()); long free = (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong()); return Long.toString((total - free) / 1048576L); } }
From source file:eu.geopaparazzi.library.util.Utilities.java
/** * Get the size in megabytes of the filesystem at 'file'. * * @param file the filesystem's path./*from w ww. j a v a 2s . com*/ * @return the size in mb. */ public static float getFilesystemMegabytes(File file) { StatFs stat = new StatFs(file.getPath()); long bytes = (long) stat.getBlockSize() * (long) stat.getBlockCount(); return bytes / (1024.f * 1024.f); }
From source file:ly.count.android.sdk.CrashDetails.java
/** * Returns the current device disk space. */// w w w . j a v a2s. co m @TargetApi(18) static String getDiskTotal() { if (android.os.Build.VERSION.SDK_INT < 18) { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = ((long) statFs.getBlockCount() * (long) statFs.getBlockSize()); return Long.toString(total / 1048576L); } else { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCountLong() * statFs.getBlockSizeLong()); return Long.toString(total / 1048576L); } }
From source file:ly.count.android.sdk.CrashDetails.java
/** * Returns the current device disk space. *//*from w w w . j a v a 2s . c o m*/ @TargetApi(18) static String getDiskCurrent() { if (android.os.Build.VERSION.SDK_INT < 18) { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = ((long) statFs.getBlockCount() * (long) statFs.getBlockSize()); long free = ((long) statFs.getAvailableBlocks() * (long) statFs.getBlockSize()); return Long.toString((total - free) / 1048576L); } else { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCountLong() * statFs.getBlockSizeLong()); long free = (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong()); return Long.toString((total - free) / 1048576L); } }
From source file:org.brandroid.openmanager.util.FileManager.java
public static boolean checkForNoMedia(OpenPath defPath) { if (defPath == null) return true; if (defPath instanceof OpenFile) { StatFs sf = new StatFs(defPath.getPath()); if (sf.getBlockCount() == 0) return true; else//from ww w .java 2s. c om return false; } else { try { return defPath.list() == null || defPath.list().length == 0; } catch (IOException e) { Logger.LogError("Error Checking for Media.", e); return true; } } }
From source file:com.almalence.util.Util.java
public static long BusyDeviceMemory() { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long Total = (statFs.getBlockCount() * statFs.getBlockSize()) / 1048576; long Free = (statFs.getAvailableBlocks() * statFs.getBlockSize()) / 1048576; return (Total - Free); }
From source file:com.almalence.util.Util.java
public static long BusyExternalMemory() { StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath()); long Total = (statFs.getBlockCount() * statFs.getBlockSize()) / 1048576; long Free = (statFs.getAvailableBlocks() * statFs.getBlockSize()) / 1048576; return (Total - Free); }
From source file:com.almalence.util.Util.java
/************************************************************************************************* * Returns size in MegaBytes.//from ww w . j av a 2 s. com * * If you need calculate external memory, change this: StatFs statFs = new * StatFs(Environment.getRootDirectory().getAbsolutePath()); to this: StatFs * statFs = new * StatFs(Environment.getExternalStorageDirectory().getAbsolutePath()); **************************************************************************************************/ public static long TotalDeviceMemory() { StatFs statFs = new StatFs(Environment.getDataDirectory().getPath()); long blockSize = statFs.getBlockSize(); long blockCount = statFs.getBlockCount(); return (blockCount * blockSize) / 1048576; }
From source file:com.almalence.util.Util.java
public static long TotalExternalMemory() { StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath()); long blockSize = statFs.getBlockSize(); long blockCount = statFs.getBlockCount(); return (blockCount * blockSize) / 1048576; }
From source file:Main.java
public long getTotalExternalMemorySize() { if (!isHaveSDCard()) { return -1; }//from ww w . j av a2 s.c o m File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long blockCount = stat.getBlockCount(); return blockSize * blockCount; }