use of android.os.StatFs in project teaTime by ancfdy.
the class SdCardUtil method getAvailableSize.
/**
* Get available size of SD card.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static long getAvailableSize(String path) {
try {
File base = new File(path);
StatFs stat = new StatFs(base.getPath());
return stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
use of android.os.StatFs in project teaTime by ancfdy.
the class AppFileMgr method getSdCardAllSize.
/**
* 获取SDCard总存储容量大小(单位byte)
* @return long 返回大小
*/
@SuppressWarnings("deprecation")
public long getSdCardAllSize() {
if (getSdCardIsEnable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
}
return 0;
}
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 getMobileEnableRAM.
/**
* 获取可用手机内容容量大小
* @return long
*/
@SuppressWarnings("deprecation")
public static long getMobileEnableRAM() {
StatFs stat = new StatFs(getDataPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks() - 4;
;
return availableBlocks * blockSize;
}
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