use of android.os.StatFs in project android_frameworks_base by AOSPA.
the class PackageManagerTests method checkInt.
private boolean checkInt(long pkgLen) {
StatFs intStats = new StatFs(Environment.getDataDirectory().getPath());
long intSize = (long) intStats.getBlockCount() * (long) intStats.getBlockSize();
long iSize = (long) intStats.getAvailableBlocks() * (long) intStats.getBlockSize();
// TODO check for thresholds here?
return pkgLen <= iSize;
}
use of android.os.StatFs in project ABPlayer by winkstu.
the class CropImage method calculatePicturesRemaining.
public static int calculatePicturesRemaining() {
try {
/*if (!ImageManager.hasStorage()) {
return NO_STORAGE_ERROR;
} else {*/
String storageDirectory = Environment.getExternalStorageDirectory().toString();
StatFs stat = new StatFs(storageDirectory);
float remaining = ((float) stat.getAvailableBlocks() * (float) stat.getBlockSize()) / 400000F;
return (int) remaining;
//}
} catch (Exception ex) {
// blank since we really don't know.
return CANNOT_STAT_ERROR;
}
}
use of android.os.StatFs in project ABPlayer by winkstu.
the class FileUtils method showFileAvailable.
/** 显示SD卡剩余空间 */
public static String showFileAvailable() {
String result = "";
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath());
long blockSize = sf.getBlockSize();
long blockCount = sf.getBlockCount();
long availCount = sf.getAvailableBlocks();
return showFileSize(availCount * blockSize) + " / " + showFileSize(blockSize * blockCount);
}
return result;
}
use of android.os.StatFs in project teaTime by ancfdy.
the class AppFileMgr method getSdCardEnableSize.
/**
* 获取SDCard卡的剩余容量(单位byte)
* @return long 返回大小
*/
@SuppressWarnings("deprecation")
public static long getSdCardEnableSize() {
//首先判断SdCard是否存在
if (getSdCardIsEnable()) {
StatFs stat = new StatFs(getSdCardAbsolutePath());
//获取空闲的数据块的数量
long availableBlocks = (long) stat.getAvailableBlocks() - 4;
//获取单个数据块的大小(byte)
long freeBlocks = stat.getAvailableBlocks();
return freeBlocks * availableBlocks;
}
return 0;
}
use of android.os.StatFs in project teaTime by ancfdy.
the class AppFileMgr method getSdCardSize.
/**
* 获取SD卡剩余空间的大小(SD卡剩余空间的大小(单位:byte))
* @return long
*/
@SuppressWarnings("deprecation")
public static long getSdCardSize() {
String str = Environment.getExternalStorageDirectory().getPath();
StatFs localStatFs = new StatFs(str);
long blockSize = localStatFs.getBlockSize();
return localStatFs.getAvailableBlocks() * blockSize;
}
Aggregations