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 getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

From source file:Main.java

public static long getTotalInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    return totalBlocks * blockSize / 1024 / 1024;
}

From source file:Main.java

public static long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = (long) stat.getBlockSize();
    long availableBlocks = (long) stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

From source file:Main.java

public static long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return blockSize * availableBlocks;
}

From source file:Main.java

public static long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize / 1024 / 1024;
}

From source file:Main.java

private static long getAvailableStorage() {
    StatFs statFs = new StatFs(root);
    long blockSize = statFs.getBlockSize();
    long availableBlocks = statFs.getAvailableBlocks();
    long availableSize = blockSize * availableBlocks;
    // Formatter.formatFileSize(context, availableSize);
    return availableSize;
}

From source file:Main.java

public static long getSdCardFree() {
    long l = 0L;/* w ww. j  a  va  2  s  .  c o  m*/
    if (Environment.getExternalStorageState().equals("mounted")) {
        StatFs statfs = new StatFs(Environment.getExternalStorageDirectory().getPath());
        l = ((long) statfs.getBlockSize() * (long) statfs.getAvailableBlocks()) / 1024L / 1024L;
    }
    return l;
}

From source file:Main.java

public static long getExternalStorageFreeSpace() {

    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());

    return stat.getAvailableBlocks() * stat.getBlockSize();
}

From source file:Main.java

public static long getAvailableMb(String path) {
    final long SIZE_KB = 1024L;
    final long SIZE_MB = SIZE_KB * SIZE_KB;
    long availableSpace = -1L;
    StatFs stat = new StatFs(path);
    availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();

    return availableSpace / SIZE_MB;
}

From source file:Main.java

static public StatFs getStatFs() {
    File path = Environment.getDataDirectory();
    return new StatFs(path.getPath());
}