List of usage examples for android.os StatFs getTotalBytes
public long getTotalBytes()
From source file:Main.java
@SuppressWarnings("unused") public static long getTotalBytes(File dir) { if (!dir.exists() && !dir.mkdirs()) { return 0; }// w w w. jav a2s . c om StatFs dirStatFs = new StatFs(dir.getPath()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { return dirStatFs.getTotalBytes(); } else { //noinspection deprecation return (long) dirStatFs.getBlockCount() * dirStatFs.getBlockSize(); } }
From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getInternalTotal() { long size;// w w w. ja va 2 s. c o m 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.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getExternalTotal() { long size;// ww w . j a va 2 s . c om StatFs extStorageStatFs; String extStoragePath = getExternalStoragePath(); if (extStoragePath == null || !(new File(extStoragePath).exists())) { return getString(R.string.sto_sub_item_ext_storage_not_available); } extStorageStatFs = new StatFs(new File(extStoragePath).getAbsolutePath()); if (mIsApiAtLeast18) { size = extStorageStatFs.getTotalBytes(); } else { size = (long) extStorageStatFs.getBlockCount() * (long) extStorageStatFs.getBlockSize(); } return Utils.getFormattedSize(size); }