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 getTotalExternalMemorySize() {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        mStatFs.restat(path.getPath());
        long blockSize = mStatFs.getBlockSize();
        long totalBlocks = mStatFs.getBlockCount();
        return totalBlocks * blockSize;
    } else {//w ww  .j  ava  2s.co  m
        return -1;
    }
}

From source file:Main.java

public static long getAvailableExternalMemorySize() {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        mStatFs.restat(path.getPath());
        long blockSize = mStatFs.getBlockSize();
        long availableBlocks = mStatFs.getAvailableBlocks();
        return availableBlocks * blockSize;
    } else {//from  ww w. j a  va  2 s.  c o  m
        return -1;
    }
}

From source file:Main.java

public static long[] getRomMemroy() {
    long[] romInfo = new long[2];
    //Total rom memory
    romInfo[0] = getTotalInternalMemorySize();

    //Available rom memory
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    romInfo[1] = blockSize * availableBlocks;
    return romInfo;
}

From source file:Main.java

public static int getDepth(File file) {
    if (file.getParent() == null || new File(file.getParent()).getPath().equals(new File(file.getPath())))
        return 1;
    return 1 + getDepth(new File(file.getParent()));
}

From source file:Main.java

public static void assertDir(File candidate) {
    if (!candidate.exists()) {
        throw new IllegalArgumentException(candidate.getPath() + " does not exist.");
    }/*from  ww w .ja  v  a  2 s.c  o m*/
    if (!candidate.isDirectory()) {
        throw new IllegalArgumentException(candidate + " is not a directory.");
    }
}

From source file:Main.java

private static String getFileDir(Context context, String dirName) {
    File file = context.getFilesDir();
    if (null != file) {
        File temp = new File(file.getPath() + "/" + dirName);
        if (!temp.exists()) {
            temp.mkdirs();// www .  j  a v a2s .  c  o m
        }
        return temp.getPath();
    }
    return null;
}

From source file:Main.java

@Nullable
public static Bitmap extractApkIcon(@NonNull final PackageManager pm, @NonNull final File file) {
    final String filePath = file.getPath();
    final PackageInfo packageInfo = pm.getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES);
    if (packageInfo != null) {
        final ApplicationInfo appInfo = packageInfo.applicationInfo;
        if (appInfo != null) {
            appInfo.sourceDir = filePath;
            appInfo.publicSourceDir = filePath;
            final Drawable icon = appInfo.loadIcon(pm);
            if (icon != null) {
                return ((BitmapDrawable) icon).getBitmap();
            }//from www.j  a va2s.  c  o m
        }
    }
    return null;
}

From source file:com.doculibre.constellio.utils.license.ApplyLicenseUtils.java

private static boolean isValidPackage(File javaFile) {
    String javaFileDotPath = javaFile.getPath().replace(File.separator, ".");
    return javaFileDotPath.indexOf("com.doculibre.constellio") != -1;
}

From source file:Main.java

public static long getTotalExternalMemorySize() {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long totalBlocks = stat.getBlockCount();
        return totalBlocks * blockSize;
    } else {/*from ww w.  ja  va  2s  .  c  o  m*/
        return -1;
    }
}

From source file:Main.java

public static long getAvailableExternalMemorySize() throws IllegalArgumentException {
    if (externalMemoryAvailable()) {
        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        return availableBlocks * blockSize;
    } else {//w ww.j  av  a  2  s.c o m
        return -1;
    }
}