List of usage examples for android.os StatFs StatFs
public StatFs(String path)
From source file:Main.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private static long getAvailable(final File dir) { final StatFs statFs = new StatFs(dir.getAbsolutePath()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { return ((long) statFs.getBlockCount()) * statFs.getBlockSize(); }//from ww w .jav a 2s . com return statFs.getBlockCountLong() * statFs.getBlockSizeLong(); }
From source file:com.bt.download.android.util.SystemUtils.java
public static long calculateDiskCacheSize(File dir, int minSize, int maxSize) { long size = minSize; try {//from ww w . j av a 2 s .com StatFs statFs = new StatFs(dir.getAbsolutePath()); long available = ((long) statFs.getBlockCount()) * statFs.getBlockSize(); // Target 2% of the total space. size = available / 50; } catch (IllegalArgumentException ignored) { } // Bound inside min/max size for disk cache. return Math.max(Math.min(size, maxSize), minSize); }
From source file:eu.mhutti1.utils.storage.StorageDevice.java
public Long getAvailableBytes() { StatFs statFs = new StatFs(mFile.getPath()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { return statFs.getBlockSizeLong() * statFs.getAvailableBlocksLong(); } else {/*from w w w . j av a 2s . com*/ return (long) statFs.getBlockSize() * (long) statFs.getAvailableBlocks(); } }
From source file:fr.eoit.activity.EOITActivity.java
/** * Called when the activity is first created. *///from www . j a v a 2 s. c o 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:eu.mhutti1.utils.storage.StorageDevice.java
public Long getTotalBytes() { StatFs statFs = new StatFs((mFile.getPath())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { return statFs.getBlockSizeLong() * statFs.getBlockCountLong(); } else {//from w w w. j a v a2s . co m return (long) statFs.getBlockSize() * (long) statFs.getBlockCount(); } }
From source file:com.esminis.server.mariadb.server.MariaDbServerLauncher.java
private long getFreeSpace(File file) { StatFs stat = new StatFs(file.getPath()); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { return stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); }// w ww . j a va2 s . c om return (long) stat.getAvailableBlocks() * (long) stat.getBlockSize(); }
From source file:org.proninyaroslav.libretorrent.core.utils.FileIOUtils.java
public static long getFreeSpace(String path) { long availableBytes = -1L; try {/*from w w w . ja va 2 s .c o m*/ File file = new File(path); availableBytes = file.getUsableSpace(); } catch (Exception e) { // this provides invalid space on some devices try { StatFs stat = new StatFs(path); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { availableBytes = stat.getAvailableBytes(); } else { availableBytes = stat.getAvailableBlocks() * stat.getBlockSize(); } } catch (Exception ee) { /* Ignore */ } } return availableBytes; }
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(); }
From source file:org.lol.reddit.common.General.java
public static boolean isCacheDiskFull(final Context context) { final StatFs stat = new StatFs(getBestCacheDir(context).getPath()); return (long) stat.getBlockSize() * (long) stat.getAvailableBlocks() < 128 * 1024 * 1024; }
From source file:com.yixia.zi.utils.UIUtils.java
public static String getAvailaleSize(Context context, String path) { File file = new File(path); if (!file.exists()) return null; StatFs stat = new StatFs(path); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(context, (availableBlocks * blockSize)); }