use of android.os.StatFs in project teaTime by ancfdy.
the class AppPhoneMgr method getSDFreeSize.
/**
* 获取sd卡剩余空间的大小
*/
@SuppressWarnings("deprecation")
public long getSDFreeSize() {
// 取得SD卡文件路径
File path = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(path.getPath());
// 获取单个数据块的大小(Byte)
long blockSize = sf.getBlockSize();
// 空闲的数据块的数量
long freeBlocks = sf.getAvailableBlocks();
// 单位MB
return (freeBlocks * blockSize) / 1024 / 1024;
}
use of android.os.StatFs in project teaTime by ancfdy.
the class AppPhoneMgr method getSDAllSize.
/**
* 获取sd卡空间的总大小
*/
@SuppressWarnings("deprecation")
public long getSDAllSize() {
// 取得SD卡文件路径
File path = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(path.getPath());
// 获取单个数据块的大小(Byte)
long blockSize = sf.getBlockSize();
// 获取所有数据块数
long allBlocks = sf.getBlockCount();
// 单位MB
return (allBlocks * blockSize) / 1024 / 1024;
}
use of android.os.StatFs in project teaTime by ancfdy.
the class FileUtils method gainSDAllSize.
/**
* 获取SD卡总容量(单位Byte)
*
* @return
*/
@SuppressWarnings("deprecation")
public static long gainSDAllSize() {
if (isMountedSDCard()) {
// 取得SD卡文件路径
File path = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(path.getPath());
// 获取单个数据块的大小(Byte)
long blockSize = sf.getBlockSize();
// 获取所有数据块数
long allBlocks = sf.getBlockCount();
// 返回SD卡大小(Byte)
return allBlocks * blockSize;
} else {
return 0;
}
}
use of android.os.StatFs in project teaTime by ancfdy.
the class FileUtils method gainSDFreeSize.
/**
* 获取SD卡剩余容量(单位Byte)
*
* @return
*/
@SuppressWarnings("deprecation")
public static long gainSDFreeSize() {
if (isMountedSDCard()) {
// 取得SD卡文件路径
File path = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(path.getPath());
// 获取单个数据块的大小(Byte)
long blockSize = sf.getBlockSize();
// 空闲的数据块的数量
long freeBlocks = sf.getAvailableBlocks();
// 单位Byte
return freeBlocks * blockSize;
} else {
return 0;
}
}
use of android.os.StatFs in project teaTime by ancfdy.
the class FileUtils method gainSDFreeSize.
/**
* 获取SD卡剩余容量(单位Byte)
*
* @return
*/
@SuppressWarnings("deprecation")
public static long gainSDFreeSize() {
if (isMountedSDCard()) {
// 取得SD卡文件路径
File path = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(path.getPath());
// 获取单个数据块的大小(Byte)
long blockSize = sf.getBlockSize();
// 空闲的数据块的数量
long freeBlocks = sf.getAvailableBlocks();
// 单位Byte
return freeBlocks * blockSize;
} else {
return 0;
}
}
Aggregations