List of usage examples for android.os StatFs getAvailableBlocks
@Deprecated public int getAvailableBlocks()
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.// w ww .j a va 2 s. co 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; final long availableBlocks; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { blockSize = stat.getBlockSizeLong(); availableBlocks = stat.getAvailableBlocksLong(); } else { //noinspection deprecation blockSize = stat.getBlockSize(); //noinspection deprecation availableBlocks = stat.getAvailableBlocks(); } return availableBlocks * blockSize; }
From source file:org.lol.reddit.common.General.java
public static boolean isCacheDiskFull(final Context context) { final StatFs stat = new StatFs(getBestCacheDir(context).getPath()); return (long) stat.getBlockSize() * (long) stat.getAvailableBlocks() < 128 * 1024 * 1024; }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device disk space. *///ww w . j a v a 2 s. c o m 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:com.intelerad.android.portal.ImageCache.java
/** * Check how much usable space is available at a given path. * //from w ww.ja va 2 s. c om * @param path The path to check * @return The space available in bytes */ @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (UiUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.bellman.bible.service.common.CommonUtils.java
public static long getFreeSpace(String path) { StatFs stat = new StatFs(path); long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks(); Log.d(TAG, "Free space :" + bytesAvailable); return bytesAvailable; }
From source file:gr.unfold.android.tsibato.images.ImageCache.java
@TargetApi(9) public static long getUsableSpace(File path) { if (Utils.hasGingerbread()) { return path.getUsableSpace(); }// ww w .ja v a 2 s . co m final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.egoists.coco_nut.android.cache.ImageCache.java
/** * Check how much usable space is available at a given path. * /*from w w w.j a v a2s . c o m*/ * @param path The path to check * @return The space available in bytes */ @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (EtcUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:ly.count.android.sdk.CrashDetails.java
/** * Returns the current device disk space. *//* w w w. jav a 2 s. 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:com.intuit.qboecoui.feeds.util.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check/* w w w . ja va 2 s. com*/ * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (ElvesUtil.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.android.volley.plus.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check/*from w w w . ja v a 2s .c om*/ * @return The space available in bytes */ // @TargetApi(9) public static long getUsableSpace(File path) { if (OsVersionUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }