List of usage examples for android.os StatFs StatFs
public StatFs(String path)
From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getInternalTotal() { long size;// ww w. ja va 2 s . c om StatFs internalStatFs = new StatFs(Environment.getDataDirectory().getAbsolutePath()); if (mIsApiAtLeast18) { size = internalStatFs.getTotalBytes(); } else { size = (long) internalStatFs.getBlockCount() * (long) internalStatFs.getBlockSize(); } return Utils.getFormattedSize(size); }
From source file:com.watabou.noosa.Game.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") public static long getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long ret;//from w ww . j a v a2 s .co m if (android.os.Build.VERSION.SDK_INT < 18) { long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); ret = availableBlocks * blockSize; } else { ret = stat.getAvailableBytes(); } Util.storeEventInAcra("FreeInternalMemorySize", Long.toString(ret)); return ret; }
From source file:com.github.piasy.common.android.utils.roms.RomUtil.java
/** * Checks if there is enough Space on SDCard * * @param updateSize Size to Check//from w ww.j a v a2 s .c o m * @return {@code true} if the Update will fit on SDCard, {@code false} if not enough space on * SDCard. Will also return false, if the SDCard is not mounted as read/write */ @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public boolean enoughSpaceOnSdCard(final long updateSize) { boolean ret = false; final String status = Environment.getExternalStorageState(); if (status.equals(Environment.MEDIA_MOUNTED)) { final File path = Environment.getExternalStorageDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ? stat.getBlockSizeLong() : stat.getBlockSize(); final long availableBlocks = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ? stat.getAvailableBlocksLong() : stat.getAvailableBlocks(); ret = updateSize < availableBlocks * blockSize; } return ret; }
From source file:com.scsy150.util.OtherUtils.java
public static long getAvailableSpace(File dir) { try {//from w ww . ja va2 s . co m final StatFs stats = new StatFs(dir.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } catch (Throwable e) { LogUtil.e("", e.getMessage()); return -1; } }
From source file:org.dkf.jmule.util.SystemUtils.java
public static long getAvailableStorageSize(File dir) { long size;//w ww . j a va2 s. c om try { StatFs stat = new StatFs(dir.getAbsolutePath()); size = ((long) stat.getAvailableBlocks()) * stat.getBlockSize(); } catch (Exception e) { size = -1; // system error computing the available storage size } return size; }
From source file:com.lidroid.util.OtherUtils.java
public static long getAvailableSpace(File dir) { try {// w w w .ja v a 2 s .c o m final StatFs stats = new StatFs(dir.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } catch (Throwable e) { Logger.e(e.getMessage(), e); return -1; } }
From source file:com.addbean.autils.tools.OtherUtils.java
public static long getAvailableSpace(File dir) { try {//from ww w . j a va2 s.c o m final StatFs stats = new StatFs(dir.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } catch (Throwable e) { return -1; } }
From source file:net.tatans.rhea.network.view.OtherUtils.java
public static long getAvailableSpace(File dir) { try {/*from ww w.ja v a 2 s .c o m*/ final StatFs stats = new StatFs(dir.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } catch (Throwable e) { TatansLogUtils.e(e.getMessage(), e); return -1; } }
From source file:com.bt.download.android.util.SystemUtils.java
public static long getAvailableStorageSize(File dir) { long size = -1; try {/* w ww .j a v a2s . c o m*/ StatFs stat = new StatFs(dir.getAbsolutePath()); size = ((long) stat.getAvailableBlocks()) * stat.getBlockSize(); } catch (Throwable e) { size = -1; // system error computing the available storage size } return size; }
From source file:cn.isif.util_plus.util.OtherUtils.java
public static long getAvailableSpace(File dir) { try {// w w w. j a va 2 s.c om final StatFs stats = new StatFs(dir.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); return -1; } }