Example usage for android.os StatFs StatFs

List of usage examples for android.os StatFs StatFs

Introduction

In this page you can find the example usage for android.os StatFs StatFs.

Prototype

public StatFs(String path) 

Source Link

Document

Construct a new StatFs for looking at the stats of the filesystem at path .

Usage

From source file:com.xiaodong.dream.catcher.demo.image.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check/* w ww  . ja  v a  2s. c  om*/
 * @return The space available in bytes
 */
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (ImageUtils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();

}

From source file:com.fireplace.market.fads.util.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * /*from  w  ww  .  jav a  2  s. co m*/
 * @param path
 *            The path to check
 * @return The space available in bytes
 */
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (Fireplace.IS_GINGERBREAD) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.p2p.misc.DeviceUtility.java

public String[] memCardDetails() {

    String[] memDetails = new String[3];

    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    double sdAvailSize = (double) stat.getAvailableBlocks() * (double) stat.getBlockSize();
    double sdtotalSize = (double) stat.getBlockCount() * (double) stat.getBlockSize();
    // One binary gigabyte equals 1,073,741,824 bytes.
    float gigaTotal = (float) (sdtotalSize / 1073741824);
    float gigaAvailable = (float) (sdAvailSize / 1073741824);
    float usedSize = gigaTotal - gigaAvailable;
    memDetails[0] = String.valueOf(gigaTotal);
    memDetails[1] = String.valueOf(gigaAvailable);
    memDetails[2] = String.valueOf(usedSize);

    return memDetails;
}

From source file:com.frostwire.android.gui.transfers.TransferManager.java

static long getCurrentMountAvailableBytes() {
    StatFs stat = new StatFs(ConfigurationManager.instance().getStoragePath());
    return ((long) stat.getBlockSize() * (long) stat.getAvailableBlocks());
}

From source file:com.haipeng.libraryforandroid.cacheormemory.imageload.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check/*from www.  java2 s.co  m*/
 * @return The space available in bytes
 */
@SuppressWarnings("deprecation")
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (SDKVersionUtil.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.kaplandroid.colorbook.utils.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * /*from  w  w  w .  j a v a2s .com*/
 * @param path
 *            The path to check
 * @return The space available in bytes
 */
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (Utils.hasGingerbread() || Utils.hasHoneycomb() || Utils.hasJellyBean()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.channelsoft.common.bitmapUtil.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check/*from  w  w  w. j a  v a2  s  .  c  o  m*/
 * @return The space available in bytes
 */
public static long getUsableSpace(File path) {

    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  .j av a 2  s . 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();
}

From source file:org.wso2.emm.system.service.api.OTAServerManager.java

public long getFreeDiskSpace() {
    StatFs statFs = new StatFs(FileUtils.getUpgradePackageDirectory());
    long freeDiskSpace = (long) statFs.getAvailableBlocks() * (long) statFs.getBlockSize();
    Log.d(TAG, "Free disk space: " + freeDiskSpace);
    return freeDiskSpace;
}

From source file:com.test.displaybitmaps.imagemanager.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * //from w  w w .j av  a  2 s . c o  m
 * @param path
 *            The path to check
 * @return The space available in bytes
 */
@TargetApi(VERSION_CODES.GINGERBREAD)
public static long getUsableSpace(File path) {
    if (Build.VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}