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.intuit.qboecoui.feeds.util.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check//www  .j  a v a2  s  .c o m
 * @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.andrew.apollo.cache.ImageCache.java

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

From source file:us.happ.bitmap.ImageCache.java

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

From source file:com.wetrain.client.customviews.imagecache.ImageCache.java

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

From source file:com.almalence.util.Util.java

/*************************************************************************************************
 * Returns size in MegaBytes./*from  w w  w.j a v  a2s  . c  om*/
 * 
 * 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.androidsx.imagesearch.util.ImageCache.java

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

From source file:eu.janmuller.android.simplecropimage.CropImage.java

public static int calculatePicturesRemaining(Activity activity) {

    try {/*from  w w  w.j  ava2s . c  o m*/
        /*if (!ImageManager.hasStorage()) {
        return NO_STORAGE_ERROR;
        } else {*/
        String storageDirectory = "";
        String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state)) {
            storageDirectory = Environment.getExternalStorageDirectory().toString();
        } else {
            storageDirectory = activity.getFilesDir().toString();
        }
        StatFs stat = new StatFs(storageDirectory);
        float remaining = ((float) stat.getAvailableBlocks() * (float) stat.getBlockSize()) / 400000F;
        return (int) remaining;
        //}
    } catch (Exception ex) {
        // 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 CANNOT_STAT_ERROR;
    }
}

From source file:com.inter.trade.imageframe.ImageCache.java

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

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:com.almalence.util.Util.java

public static long FreeDeviceMemory() {
    StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
    long blockSize = statFs.getBlockSize();
    long availableBloks = statFs.getAvailableBlocks();
    return (availableBloks * blockSize) / 1048576;
}