List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:net.wespot.pim.utils.images.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check/* w w w . java2 s . c o m*/ * @return The space available in bytes */ @TargetApi(Build.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.cyberocw.habittodosecretary.file.StorageHelper.java
/** * Returns a directory size in bytes//from w ww . j av a2s . c o m */ @SuppressWarnings("deprecation") public static long getSize(File directory) { StatFs statFs = new StatFs(directory.getAbsolutePath()); long blockSize = 0; try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { blockSize = statFs.getBlockSizeLong(); } else { blockSize = statFs.getBlockSize(); } // Can't understand why on some devices this fails } catch (NoSuchMethodError e) { Log.e(Const.ERROR_TAG, "Mysterious error", e); } return getSize(directory, blockSize); }
From source file:eu.janmuller.android.simplecropimage.CropImage.java
public static int calculatePicturesRemaining(Activity activity) { try {/* w w w. jav a2s . c o m*/ /*if (!ImageManager.hasStorage()) { return NO_STORAGE_ERROR; } else {*/ String storageDirectory = ""; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { storageDirectory = Environment.getExternalStorageDirectory().toString(); } else { storageDirectory = activity.getFilesDir().toString(); } StatFs stat = new StatFs(storageDirectory); float remaining = ((float) stat.getAvailableBlocks() * (float) stat.getBlockSize()) / 400000F; return (int) remaining; //} } catch (Exception ex) { // if we can't stat the filesystem then we don't know how many // pictures are remaining. it might be zero but just leave it // blank since we really don't know. return CANNOT_STAT_ERROR; } }
From source file:com.rp.justcast.photos.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check// w ww.j a v a 2 s . c o m * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (JustCastUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.chatitzemoumin.londoncoffeeapp.util.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check//from w ww .ja v a 2 s.c o m * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (PlatformUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:wb.android.cache.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check/*ww w . j a v a 2 s. co m*/ * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) @SuppressWarnings("deprecation") public static long getUsableSpace(File path) { if (Utils.ApiHelper.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:android.bitmap.util.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check//from w w w. java 2 s .c o m * @return The space available in bytes */ @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.android.fragmentbase.cache.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check/*from w w w . j av a 2 s . c o m*/ * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (ImageUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.common.library.bitmap.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check// w w w .j a va2 s . c o m * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) public static long getUsableSpace(File path) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.dycody.android.idealnote.utils.StorageHelper.java
/** * Returns a directory size in bytes//from w ww. j a v a 2s .c o m */ @SuppressWarnings("deprecation") public static long getSize(File directory) { StatFs statFs = new StatFs(directory.getAbsolutePath()); long blockSize = 0; try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { blockSize = statFs.getBlockSizeLong(); } else { blockSize = statFs.getBlockSize(); } // Can't understand why on some devices this fails } catch (NoSuchMethodError e) { Log.e(Constants.TAG, "Mysterious error", e); } return getSize(directory, blockSize); }