Example usage for android.os StatFs getAvailableBlocks

List of usage examples for android.os StatFs getAvailableBlocks

Introduction

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

Prototype

@Deprecated
public int getAvailableBlocks() 

Source Link

Usage

From source file:com.wowcow.chat10.imagecache.ImageCache.java

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

From source file:com.andreaszeiser.bob.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * //  w w  w.jav  a  2  s  .  c  o  m
 * @param path
 *            The path to check
 * @return The space available in bytes
 */
@TargetApi(9)
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.tack.android.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  2  s . co m*/
 * @return The space available in bytes
 */
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (ConfigUtil.hasV09()) {
        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.
 * /*  www.  j a v  a  2  s.  c  o 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.test.displaybitmaps.imagemanager.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * /*from  w  w w. jav a2s .  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();
}

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// ww  w . ja  v a  2s.c om
 * @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.kaplandroid.colorbook.utils.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * // ww w .  ja v a 2 s  . c om
 * @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.watabou.noosa.Game.java

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long ret;/*from   w  ww.  ja  v  a2 s.com*/
    if (android.os.Build.VERSION.SDK_INT < 18) {
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        ret = availableBlocks * blockSize;
    } else {
        ret = stat.getAvailableBytes();
    }
    Util.storeEventInAcra("FreeInternalMemorySize", Long.toString(ret));
    return ret;
}

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

public static int calculatePicturesRemaining(Activity activity) {

    try {/* ww  w. j  av a  2  s  .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.frostwire.android.gui.transfers.TransferManager.java

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