List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
public static Drawable getDrawableFromFile(Context context, File pngFile, int density) { Bitmap bmp = BitmapFactory.decodeFile(pngFile.getPath()); if (bmp != null) bmp.setDensity(density);//www . j a va2 s .com return new BitmapDrawable(context.getResources(), bmp); }
From source file:Main.java
private static String getResourcesPath(Context context, String url) { String dir = String.format("/Android/data/%s/files/", context.getPackageName()); File sd = Environment.getExternalStorageDirectory(); File filePath = new File(sd.getPath() + dir + "savedResources"); filePath.mkdirs();/*from ww w.j a v a 2 s .c om*/ return filePath + url.substring(url.lastIndexOf("/")); }
From source file:Main.java
public static List grabFiles() { List<String> tFileList = new ArrayList<String>(); String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/nexsight/"; File f = new File(p); Log.d(TAG, "Read from " + p); File[] files = f.listFiles(); files = flipArray(files);/*from www. j a v a2 s .co m*/ if (files != null) { for (int i = 0; i < files.length; i++) { File file = files[i]; tFileList.add(file.getPath()); } } else { Log.w(TAG, "nothing found in " + p); } return tFileList; }
From source file:Main.java
public static long getAvailableInnerSpace() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); long realSize = blockSize * availableBlocks; return realSize; }
From source file:Main.java
@SuppressWarnings("deprecation") public static long getAvailableSD() { File path = Environment.getExternalStorageDirectory(); StatFs statFs = new StatFs(path.getPath()); long blockSize = statFs.getBlockSize(); long blockCount = statFs.getBlockCount(); long availableBlocks = statFs.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
/** * Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM.//w w w . j a v a 2s. c o m * * @return Number of bytes available. */ public static long getAvailableInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = stat.getBlockSize(); final long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
public static void createDir(String dirPath) { File dir = new File(dirPath); if (!dir.exists()) { Log.d("createDir", dir.getPath() + " does not exist. Creating"); if (!dir.mkdir()) { Log.e("createDir", "Unable to create " + dir.getPath()); }// ww w .j a v a2s . co m } }
From source file:Main.java
/** * Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM.//from w ww. ja v a2 s . c o m * * @return Total number of bytes. */ public static long getTotalInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = stat.getBlockSize(); final long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; }
From source file:Main.java
/** * @return Total internal memory/*ww w.j av a2 s. c o m*/ */ public static int getTotalInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); int blockSize = stat.getBlockSize(); int totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; }
From source file:Main.java
/** * @return Available internal memory/*from w w w . j a v a 2s .c om*/ */ public static int getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); int blockSize = stat.getBlockSize(); int availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }