/**
* Returns the total size in bytes of the partition containing this path.
* Returns 0 if this path does not exist.
*
* @param path
* @return -1 means path is null, 0 means path is not exist.
*/
public static long getTotalSpace(File path) {
if (path == null) {
return -1;
}
return path.getTotalSpace();
}
/**
* Returns the total size in bytes of the partition containing this path.
* Returns 0 if this path does not exist.
*
* @param path
* @return -1 means path is null, 0 means path is not exist.
*/
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
// using @TargeApi instead of @SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static long getTotalSpace(File path) {
if (path == null) {
return -1;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
return path.getTotalSpace();
}
// implements getTotalSpace() in API lower than GINGERBREAD
else {
if (!path.exists()) {
return 0;
} else {
final StatFs stats = new StatFs(path.getPath());
// Using deprecated method in low API level system,
// add @SuppressWarnings("description") to suppress the warning
return (long) stats.getBlockSize() * (long) stats.getBlockCount();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有