Example usage for android.os StatFs getBlockSize

List of usage examples for android.os StatFs getBlockSize

Introduction

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

Prototype

@Deprecated
public int getBlockSize() 

Source Link

Usage

From source file:eu.geopaparazzi.library.util.Utilities.java

/**
 * Get the megabytes available in the filesystem at 'file'.
 *
 * @param file the filesystem's path.//from ww w. j a  v  a 2  s . co  m
 * @return the available space in mb.
 */
public static float getAvailableMegabytes(File file) {
    StatFs stat = new StatFs(file.getPath());
    long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
    return bytesAvailable / (1024.f * 1024.f);
}

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.
 *///w  w w.  ja v a2 s  . c  o  m
static String getDiskTotal() {
    if (android.os.Build.VERSION.SDK_INT < 18) {
        StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
        long total = (statFs.getBlockCount() * 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:count.ly.messaging.CrashDetails.java

/**
 * Returns the current device disk space.
 *///ww w .j  a  v a2  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.secbro.qark.filebrowser.FileBrowserFragment.java

public static long getFreeSpace(String path) {
    StatFs stat = new StatFs(path);
    long availSize = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
    return availSize;
}

From source file:com.intelerad.android.portal.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * //  w  w  w.j  ava2s.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 (UiUtils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.callrecorder.android.FileHelper.java

@SuppressWarnings("deprecation")
public static long getFreeSpaceAvailable(String path) {
    StatFs stat = new StatFs(path);
    long availableBlocks;
    long blockSize;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        availableBlocks = stat.getAvailableBlocksLong();
        blockSize = stat.getBlockSizeLong();
    } else {/* w  ww . j  ava 2s.c o m*/
        availableBlocks = stat.getAvailableBlocks();
        blockSize = stat.getBlockSize();
    }
    return availableBlocks * blockSize;
}

From source file:ly.count.android.sdk.CrashDetails.java

/**
 * Returns the current device disk space.
 *//*from  w  w  w. j a  v  a 2  s .  c o  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: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:ly.count.android.sdk.CrashDetails.java

/**
 * Returns the current device disk space.
 *//*  w  ww. j  a va2s. c  om*/
@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);
    }
}