Example usage for android.os StatFs getBlockSize

List of usage examples for android.os StatFs getBlockSize

Introduction

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

Prototype

@Deprecated
public int getBlockSize() 

Source Link

Usage

From source file:Main.java

public static long getAvailableSpace(File dir) {
    try {/*w  w  w  .  j av  a 2s.co m*/
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        Log.e("getAvailableSpace", e.getMessage(), e);
        return -1;
    }
}

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;
    }/*w  w w .  j  a  va2 s  .  c o m*/

    return availableSize / (1024 * 1024);
}

From source file:Main.java

/**
 * get the space is left over on phone self
 *//* w ww.  j  a v  a2  s . c o  m*/
public static long getRealSizeOnPhone() {
    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 getAvailableROM() {
    File dataDirectory = Environment.getDataDirectory();
    StatFs statFs = new StatFs(dataDirectory.getPath());
    long blockSize = statFs.getBlockSize();
    long blockCount = statFs.getBlockCount();
    long availableBlocks = statFs.getAvailableBlocks();
    return availableBlocks * blockSize;
}

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 getFreeSpaceOnDevice() {
    StatFs localStatFs = new StatFs(Environment.getDataDirectory().getPath());
    return localStatFs.getBlockSize() * localStatFs.getAvailableBlocks();
}

From source file:Main.java

private static boolean checkMicroSDCard(String fileSystemName) {
    StatFs statFs = new StatFs(fileSystemName);

    long totalSize = (long) statFs.getBlockSize() * statFs.getBlockCount();

    if (totalSize < 1024 * 1024 * 1024 * 1024) {
        return false;
    }/*from w  ww. ja  v a2  s .c o m*/

    return true;
}

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 computeFreeSpace() {
    File dataDir = Environment.getDataDirectory();
    StatFs stat = new StatFs(dataDir.getPath());
    return stat.getAvailableBlocks() * stat.getBlockSize();
}