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:Main.java

public static long getPathSpace(String path) {
    StatFs statFs = new StatFs(path);
    return statFs.getBlockSize() * (long) statFs.getAvailableBlocks();
}

From source file:Main.java

private static long getTotalSize(String path) {
    StatFs fileStats = new StatFs(path);
    fileStats.restat(path);// ww  w . j av  a  2s  . c o  m
    return (long) fileStats.getBlockCount() * fileStats.getBlockSize();
}

From source file:Main.java

public static long getSDAllSize() {
    StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
    return ((((long) sf.getBlockCount()) * ((long) sf.getBlockSize())) / 1024) / 1024;
}

From source file:Main.java

public static long getSDFreeSize() {
    StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
    return ((((long) sf.getAvailableBlocks()) * ((long) sf.getBlockSize())) / 1024) / 1024;
}

From source file:Main.java

public static long calculateUsedDiskSpaceInBytes(String path) {
    StatFs statFs = new StatFs(path);
    long blockSizeBytes = (long) statFs.getBlockSize();
    return (blockSizeBytes * ((long) statFs.getBlockCount()))
            - (blockSizeBytes * ((long) statFs.getAvailableBlocks()));
}

From source file:Main.java

public static long FreeMemory() {
    StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
    long Free = (statFs.getAvailableBlocksLong() * statFs.getBlockSize()) / 1048576;
    return Free;/*from w w w .  j  av  a 2s  . co  m*/
}

From source file:Main.java

static public long getFreeSpaceOnSD() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    return stat.getAvailableBlocks() * stat.getBlockSize();
}

From source file:Main.java

public static long freeSpaceOnSd() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long sdFreeMB = (long) stat.getAvailableBlocks() * stat.getBlockSize();
    return sdFreeMB;
}

From source file:Main.java

public static long getFreeSpaceOnDevice() {
    StatFs localStatFs = new StatFs(Environment.getDataDirectory().getPath());
    return localStatFs.getBlockSize() * localStatFs.getAvailableBlocks();
}

From source file:Main.java

public static boolean checkStorageSpace() {

    StatFs stat = new StatFs(Environment.getDataDirectory().getAbsolutePath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();

    if (blockSize * availableBlocks / 1024 / 1024 >= 128) {
        return true;
    }/*from w w w .j a va 2s  .com*/

    return false;
}