List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the available internal memory size *///from ww w. j av a2 s . co m public double getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); double blockSize = stat.getBlockSize(); double availableBlocks = stat.getAvailableBlocks(); return formatSizeGB(availableBlocks * blockSize); }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the total internal memory size//from www .j a v a 2 s .co m */ public double getTotalInternalMemorySize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); double blockSize = stat.getBlockSize(); double totalBlocks = stat.getBlockCount(); return formatSizeGB(totalBlocks * blockSize); }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the available external memory size *///from www. j ava 2 s. co m public double getAvailableExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); double blockSize = stat.getBlockSize(); double availableBlocks = stat.getAvailableBlocks(); return formatSizeGB(availableBlocks * blockSize); } else { return ERROR; } }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the total external memory size/*from w w w. j a va2s . c o m*/ */ public double getTotalExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); double blockSize = stat.getBlockSize(); double totalBlocks = stat.getBlockCount(); return formatSizeGB(totalBlocks * blockSize); } else { return ERROR; } }
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 ww . ja v a 2 s. c om*/ return (long) statFs.getBlockSize() * (long) statFs.getBlockCount(); } }
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 {//w ww .j a va 2s .c om return (long) statFs.getBlockSize() * (long) statFs.getAvailableBlocks(); } }
From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getInternalTotal() { long size;/*from www .j a va 2s .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:rus.cpuinfo.AndroidDepedentModel.DevInfo.java
@NonNull @SuppressLint("NewApi") private String getInternalStorage() { StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath()); final long blockCount = VersionUtil.IS_JELLY_BEAN_MR2() ? statFs.getBlockCountLong() * statFs.getBlockSizeLong() : statFs.getBlockCount() * statFs.getBlockSize(); // return String.format(Locale.getDefault(),"%s",blockCount); return formatFileSize(getContext(), blockCount); }
From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getInternalFree() { long size;/* w w w . j ava2 s . c o m*/ StatFs internalStatFs = new StatFs(Environment.getDataDirectory().getAbsolutePath()); if (mIsApiAtLeast18) { size = internalStatFs.getAvailableBytes(); } else { size = (long) internalStatFs.getAvailableBlocks() * (long) internalStatFs.getBlockSize(); } return Utils.getFormattedSize(size); }
From source file:rus.cpuinfo.AndroidDepedentModel.DevInfo.java
@NonNull @SuppressLint("NewApi") private String getAviableStorage() { StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath()); final long availBlocks = VersionUtil.IS_JELLY_BEAN_MR2() ? statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong() : statFs.getAvailableBlocks() * statFs.getBlockSize(); // return String.format(Locale.getDefault(),"%s",availBlocks); return formatFileSize(getContext(), availBlocks).replaceAll(",", "."); }