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

public static String getInternalMemory(Context context) {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return Formatter.formatFileSize(context, availableBlocks * blockSize);
}

From source file:Main.java

public static long getAvailableExternalSpace() {
    File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
    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 availableSDCard() {
    File path = Environment.getExternalStorageDirectory();
    long availableSize = 0;
    if (path != null) {
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlock = stat.getAvailableBlocks();
        availableSize = availableBlock * blockSize;
    }//from w  w  w .j a  v  a  2 s. c  om

    return availableSize / (1024 * 1024);
}

From source file:Main.java

/**
 * @return Available internal memory/*  w  w w.ja  v a2 s . co  m*/
 */
public static int getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    int blockSize = stat.getBlockSize();
    int availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

From source file:Main.java

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

From source file:Main.java

public static long getSdCardFree() {
    long l = 0L;/* ww  w .j a  v  a 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 getAvailableExternalMemorySize() {
    File path = Environment.getExternalStorageDirectory();
    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 getSdAvailaleSize() {
    if (!isSdCardExist()) {
        return 0;
    }//from w w w.j av  a 2s. c o m

    StatFs stat = new StatFs(getSDPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
}

From source file:Main.java

public static long getAvailableExternalMemorySize() throws IllegalArgumentException {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        return availableBlocks * blockSize;
    } else {/* www. j  a v a  2  s  . c  om*/
        return -1;
    }
}

From source file:Main.java

public static long[] getRomMemroy() {
    long[] romInfo = new long[2];
    //Total rom memory
    romInfo[0] = getTotalInternalMemorySize();

    //Available rom memory
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    romInfo[1] = blockSize * availableBlocks;
    return romInfo;
}