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 long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = (long) stat.getBlockSize();
    long availableBlocks = (long) 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 blockSize * availableBlocks;
}

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

From source file:Main.java

static public StatFs getStatFs() {
    File path = Environment.getDataDirectory();
    return new StatFs(path.getPath());
}

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

@SuppressWarnings("deprecation")
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

/**
 * get the space is left over on phone self
 *//*  w  w  w.  j  a va 2  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();
    return blockSize * availableBlocks;
}

From source file:Main.java

public static String getSDCardPath() {
    return checkSDCard() ? Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator
            : Environment.getDataDirectory().getAbsolutePath() + File.separator;
}

From source file:Main.java

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

From source file:Main.java

/**
 * Returns the number of free bytes on the storage.
 */// w  w w .  j a  va2 s .  c o  m
public static long getFreeSpaceInBytes() {
    return Environment.getDataDirectory().getUsableSpace();
}