Example usage for java.io File getPath

List of usage examples for java.io File getPath

Introduction

In this page you can find the example usage for java.io File getPath.

Prototype

public String getPath() 

Source Link

Document

Converts this abstract pathname into a pathname string.

Usage

From source file:Main.java

public static long getUsableSpace(File path) {
    final StatFs stats = new StatFs(path.getPath());
    return stats.getBlockCount() * stats.getAvailableBlocks();
}

From source file:Main.java

/**
 * Decodes an image File to Bitmap without resizing the image.<br>
 * Be careful, if the image is big this can become a problem because it will use to much memory.
 * @param file the image file reference//from  w  w w.j a  v a  2 s  .  c  o  m
 * @return the Bitmap
 */
public static Bitmap decodeBitmapFromFile(File file) {
    return BitmapFactory.decodeFile(file.getPath());
}

From source file:Main.java

public static Drawable getDrawableFromFile(File pngFile) {

    return Drawable.createFromPath(pngFile.getPath());
}

From source file:Main.java

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

From source file:Main.java

public static long getAvailableInternalMemorySize() {
    File path = Environment.getDataDirectory();
    mStatFs.restat(path.getPath());
    long blockSize = mStatFs.getBlockSize();
    long availableBlocks = mStatFs.getAvailableBlocks();
    return availableBlocks * blockSize;
}

From source file:Main.java

/**
 * the number of bytes on the filesystem rooted at the given File
 * //from   w  ww. j a  v a 2  s .c  o  m
 * @param root
 *            root file dir.
 * @return the number of bytes available on the filesystem rooted at the
 *         given File
 */
public static long getTotaltes(File root) {
    StatFs stat = new StatFs(root.getPath());
    // put a bit of margin (in case creating the file grows the system by a
    // few blocks)
    long availableBlocks = (long) stat.getBlockCount() - 4; // SUPPRESS
    // CHECKSTYLE //
    // CHECKSTYLE
    return stat.getBlockSize() * availableBlocks;
}

From source file:Main.java

public static long getAvailableSpace(File dir) {
    try {//from ww w  .jav a2 s . c o 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 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 computeFreeSpace() {
    File dataDir = Environment.getDataDirectory();
    StatFs stat = new StatFs(dataDir.getPath());
    return stat.getAvailableBlocks() * stat.getBlockSize();
}

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