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

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

From source file:Main.java

static public long getAvailableInternalMemorySize(StatFs stat) {
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

From source file:Main.java

public static int freeSpaceOnSd() {
    StatFs stat = new StatFs(getSDPath());
    double sdFree = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize());
    return (int) sdFree;
}

From source file:Main.java

/**
 * @return The available storage in MegaBytes
 *//*  w w  w .  j  a va 2 s .  c  om*/
public static Long getAvailableInternalDataSize() {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    long size = stat.getAvailableBlocks() * stat.getBlockSize();
    return size / BYTES_TO_MB;
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static long getSize(StatFs statFs) {
    int blockSize = statFs.getBlockSize();
    int availableBlocks = statFs.getAvailableBlocks();
    return (blockSize * availableBlocks) / (1024 * 1024);
}

From source file:Main.java

public static long getAvailableStorage() {
    String storageDirectory = null;
    storageDirectory = Environment.getExternalStorageDirectory().toString();

    try {/*from w  ww  .  j a v a2s .  co m*/
        StatFs stat = new StatFs(storageDirectory);
        long avaliableSize = ((long) stat.getAvailableBlocks() * (long) stat.getBlockSize());
        return avaliableSize;
    } catch (RuntimeException ex) {
        return 0;
    }
}

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

/**
 * @return the number of bytes available on the filesystem rooted at the given File
 *//*from   ww  w .  ja v a  2  s  . co m*/
public static long getAvailableBytes(File root) {
    StatFs stat = new StatFs(root.getPath());
    long availableBlocks = (long) stat.getAvailableBlocks() - 4;
    return stat.getBlockSize() * availableBlocks;
}

From source file:Main.java

public static boolean isAvailableExternalMemory(File paramFile) {
    StatFs localStatFs = new StatFs(paramFile.getPath());
    return (int) (localStatFs.getBlockSize() * localStatFs.getAvailableBlocks() / 1048576L) > 15;
}

From source file:Main.java

public static long getUsableSpace(File path) {
    final StatFs stats = new StatFs(path.getPath());
    return stats.getBlockCount() * stats.getAvailableBlocks();
}