List of usage examples for android.os StatFs getAvailableBlocks
@Deprecated public int getAvailableBlocks()
From source file:com.andrew.apollo.cache.ImageCache.java
/** * Check how much usable space is available at a given path. * /*from w ww . ja v a 2s. c om*/ * @param path The path to check * @return The space available in bytes */ @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static final long getUsableSpace(final File path) { if (ApolloUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:air.com.snagfilms.utils.ImageCache.java
/** * Check how much usable space is available at a given path. * //from w ww.java 2 s .com * @param path * The path to check * @return The space available in bytes */ @SuppressWarnings("deprecation") @TargetApi(VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (Utils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.pdftron.pdf.utils.Utils.java
public static String copyResourceToTempFolder(Context context, int resId, boolean force, String resourceName) throws PDFNetException { if (context == null) { throw new PDFNetException("", 0L, "com.pdftron.pdf.PDFNet", "copyResourceToTempFolder()", "Context cannot be null to initialize resource file."); } else {/*from w w w .j av a2 s.co m*/ File resFile = new File(context.getFilesDir() + File.separator + "resourceName"); if (!resFile.exists() || force) { File filesDir = context.getFilesDir(); StatFs stat = new StatFs(filesDir.getPath()); long size = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize(); if (size < 2903023L) { throw new PDFNetException("", 0L, "com.pdftron.pdf.PDFNet", "copyResourceToTempFolder()", "Not enough space available to copy resources file."); } Resources rs = context.getResources(); try { InputStream e = rs.openRawResource(resId); FileOutputStream fos = context.openFileOutput(resourceName, 0); byte[] buffer = new byte[1024]; int read; while ((read = e.read(buffer)) != -1) { fos.write(buffer, 0, read); } e.close(); fos.flush(); fos.close(); } catch (Resources.NotFoundException var13) { throw new PDFNetException("", 0L, "com.pdftron.pdf.PDFNet", "initializeResource()", "Resource file ID does not exist."); } catch (FileNotFoundException var14) { throw new PDFNetException("", 0L, "com.pdftron.pdf.PDFNet", "initializeResource()", "Resource file not found."); } catch (IOException var15) { throw new PDFNetException("", 0L, "com.pdftron.pdf.PDFNet", "initializeResource()", "Error writing resource file to internal storage."); } catch (Exception var16) { throw new PDFNetException("", 0L, "com.pdftron.pdf.PDFNet", "initializeResource()", "Unknown error."); } } return context.getFilesDir().getAbsolutePath(); } }
From source file:com.almalence.util.Util.java
public static long FreeDeviceMemory() { StatFs statFs = new StatFs(Environment.getDataDirectory().getPath()); long blockSize = statFs.getBlockSize(); long availableBloks = statFs.getAvailableBlocks(); return (availableBloks * blockSize) / 1048576; }
From source file:com.almalence.util.Util.java
public static long FreeExternalMemory() { StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath()); long blockSize = statFs.getBlockSize(); long availableBloks = statFs.getAvailableBlocks(); return (availableBloks * blockSize) / 1048576; }
From source file:com.almalence.util.Util.java
public static long BusyDeviceMemory() { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long Total = (statFs.getBlockCount() * statFs.getBlockSize()) / 1048576; long Free = (statFs.getAvailableBlocks() * statFs.getBlockSize()) / 1048576; return (Total - Free); }
From source file:com.almalence.util.Util.java
public static long BusyExternalMemory() { StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath()); long Total = (statFs.getBlockCount() * statFs.getBlockSize()) / 1048576; long Free = (statFs.getAvailableBlocks() * statFs.getBlockSize()) / 1048576; return (Total - Free); }
From source file:com.dv.Utils.DvFileUtil.java
/** * sdcard.//ww w.j a v a2 s. co m * * @return the int */ public static int freeSpaceOnSD() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()) / MB; return (int) sdFreeMB; }
From source file:com.just.agentweb.AgentWebUtils.java
public static long getAvailableStorage() { try {/*w w w.j a v a 2 s . c o m*/ StatFs stat = new StatFs(Environment.getExternalStorageDirectory().toString()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { return stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); } else { return (long) stat.getAvailableBlocks() * (long) stat.getBlockSize(); } } catch (RuntimeException ex) { return 0; } }
From source file:cn.org.eshow.framwork.util.AbFileUtil.java
/** * sdcard./*from w w w . ja v a 2s .com*/ * * @return the int */ public static int freeSpaceOnSD() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()) / 1024 * 1024; return (int) sdFreeMB; }