Example usage for android.os StatFs getBlockSizeLong

List of usage examples for android.os StatFs getBlockSizeLong

Introduction

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

Prototype

public long getBlockSizeLong() 

Source Link

Document

The size, in bytes, of a block on the file system.

Usage

From source file:com.colorchen.qbase.utils.FileUtil.java

/**
 * ?SD?//from w w  w.  j  ava 2s  .  c om
 *
 * @return SD?
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getFreeSpace() {
    if (!isSDCardEnable()) {
        return "sdcard unable!";
    }
    StatFs stat = new StatFs(getSDCardPath());
    long blockSize, availableBlocks;
    availableBlocks = stat.getAvailableBlocksLong();
    blockSize = stat.getBlockSizeLong();
    return DataUtil.byte2FitSize(availableBlocks * blockSize);
}

From source file:com.miz.functions.MizLib.java

@SuppressWarnings("deprecation")
public static long getFreeMemory() {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    if (hasJellyBeanMR2())
        return stat.getAvailableBlocksLong() * stat.getBlockSizeLong();
    else/*from ww  w.ja va2s. c  o m*/
        return stat.getAvailableBlocks() * stat.getBlockSize();
}