List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:com.atwal.wakeup.battery.util.Utilities.java
public static long getTotalExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; } else {/* w w w . jav a 2 s.c om*/ return 0; } }
From source file:com.dv.Utils.DvFileUtil.java
/** * sdcard./* w w w . j a v a2 s. c o 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 {//from ww w .jav a 2 s.co 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.// w w w . jav a 2 s .c o m * * @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; }
From source file:fr.eoit.activity.EOITActivity.java
/** * Called when the activity is first created. *//*from w ww .j a v a 2 s . co m*/ @Override public void onCreate(Bundle savedInstanceState) { loadParametersOnCreate = false; super.onCreate(savedInstanceState); setContentView(R.layout.main); disableConnectionReuseIfNecessary(); enableHttpResponseCache(); bar = (ProgressBar) findViewById(R.id.progressBar); bar.setIndeterminate(true); infoTextView = (TextView) findViewById(R.id.textView); File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); if (blockSize * availableBlocks > EOITConst.APPLICATION_SIZE) { new LoadItemsAsyncTask().execute(this); } else { new AlertDialog.Builder(this).setCancelable(false).setTitle(R.string.database_no_space) .setMessage(getResources().getString(R.string.database_no_space_message, EOITConst.APPLICATION_SIZE / (1024 * 1024))) .setIcon(android.R.drawable.ic_dialog_alert) .setNegativeButton(R.string.database_locked_close_button_message, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { finish(); } }) .create().show(); } }
From source file:com.doomy.padlock.InfoFragment.java
/** * Gets available internal memory size. *// w w w . j a va 2 s. c o m * @return The size of internal storage available. */ public String getAvailableInternalMemorySize() { File mPath = Environment.getDataDirectory(); StatFs mStat = new StatFs(mPath.getPath()); long mBlockSize = mStat.getBlockSize(); long mAvailableBlocks = mStat.getAvailableBlocks(); return Formatter.formatFileSize(getActivity(), mAvailableBlocks * mBlockSize); }
From source file:com.doomy.padlock.InfoFragment.java
/** * Gets total internal memory size.//from ww w . j a v a 2s . co m * * @return The total size of internal storage. */ public String getTotalInternalMemorySize() { File mPath = Environment.getDataDirectory(); StatFs mStat = new StatFs(mPath.getPath()); long mBlockSize = mStat.getBlockSize(); long mTotalBlocks = mStat.getBlockCount(); return Formatter.formatFileSize(getActivity(), mTotalBlocks * mBlockSize); }
From source file:cordova.plugins.Diagnostic_External_Storage.java
/** * Given a path return the number of free bytes in the filesystem containing the path. * * @param path to the file system/* w w w . j av a 2 s .c o m*/ * @return free space in bytes */ protected long getFreeSpaceInBytes(String path) { try { StatFs stat = new StatFs(path); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; } catch (IllegalArgumentException e) { // The path was invalid. Just return 0 free bytes. return 0; } }
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 a 2 s .com * @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:org.navitproject.navit.NavitDownloadSelectMapActivity.java
private long getFreeSpace() { StatFs fsInfo = new StatFs(Navit.map_filename_path); return (long) fsInfo.getAvailableBlocks() * fsInfo.getBlockSize(); }