List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
public static long getAvailableSize(String path) { try {/*from ww w. j a v a2s . co m*/ File base = new File(path); StatFs stat = new StatFs(base.getPath()); long nAvailableCount = stat.getBlockSize() * ((long) stat.getAvailableBlocks()); return nAvailableCount; } catch (Exception e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static int getOrientation(File file) { return getOrientation(file.getPath()); }
From source file:Main.java
public static long getExternalStorageFreeSpace() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); return stat.getAvailableBlocks() * stat.getBlockSize(); }
From source file:Main.java
public static String storageDir(Context context) { if (useExternalStorage) { return extStorageDir(context); }/*from w w w.ja va 2 s .co m*/ File mediaStorageDir = context.getFilesDir(); return mediaStorageDir.getPath() + File.separator; }
From source file:Main.java
public static double getDirUsageCapacity(String filePath) { File file = new File(filePath); if (!file.exists()) { return 0; }//from ww w.ja v a 2 s.c om if (file.isDirectory()) { double size = 0; for (File f : file.listFiles()) { size += getDirUsageCapacity(f.getPath()); } return size; } else { return file.length(); } }
From source file:Main.java
/** * get the space is left over on phone self */// w w w . j ava 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(); long realSize = blockSize * availableBlocks; return realSize; }
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
public static String getSDTotalSize(Context context) { File path = Environment.getExternalStorageDirectory(); 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
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); }
From source file:Main.java
@SuppressWarnings("deprecation") public static Drawable getDrawableFromFile(File pngFile, int density) { Bitmap bmp = BitmapFactory.decodeFile(pngFile.getPath()); bmp.setDensity(density);//from ww w. j a va 2 s . c o m return new BitmapDrawable(bmp); }