Example usage for android.os Environment getDataDirectory

List of usage examples for android.os Environment getDataDirectory

Introduction

In this page you can find the example usage for android.os Environment getDataDirectory.

Prototype

public static File getDataDirectory() 

Source Link

Document

Return the user data directory.

Usage

From source file:Main.java

public static String getDataPath() {
    return Environment.getDataDirectory() + "/data/";
}

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

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   ww  w.j a v a  2s . co  m*/

    return false;
}

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;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static long getInternalMemorySize() {
    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 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;
}