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

From source file:Main.java

public static String getMemTotalSize(Context ctx) {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    return Formatter.formatFileSize(ctx, blockSize * totalBlocks);
}

From source file:Main.java

public static String getRootDir() {
    if (isHasSdcard()) {
        return Environment.getExternalStorageDirectory().getAbsolutePath() + "/YLTadm/";
    } else {/*from   ww  w  . j  a va2 s  .  c om*/
        return Environment.getDataDirectory().getAbsolutePath() + "/";
    }
}

From source file:Main.java

/**
 * Returns the number of total bytes on the storage.
 *//*www  .j av  a2 s. com*/
public static long getTotalSpaceInBytes() {
    return Environment.getDataDirectory().getTotalSpace();
}

From source file:Main.java

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

From source file:Main.java

public static String getAvailableInternalMemorySize(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 String getRootFilePath() {
    if (hasSDCard()) {
        return Environment.getExternalStorageDirectory().getAbsolutePath() + "/";// filePath:/sdcard/
    } else {//w w  w . j a v a  2  s. c  o  m
        return Environment.getDataDirectory().getAbsolutePath() + "/data/"; // filePath: /data/data/
    }
}

From source file:Main.java

public static String getStorageSize(Context context) {
    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
    return Formatter.formatFileSize(context, ((long) stat.getBlockSize()) * ((long) stat.getBlockCount()));
}

From source file:Main.java

public static File getSavePath() {
    File path;//from w ww .j a  va 2  s. c  o  m
    if (hasSDCard()) { // SD card
        path = new File(getSDCardPath() + "/flipbook/");
        path.mkdir();
    } else {
        path = Environment.getDataDirectory();
    }
    return path;
}

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