String path=Environment.getDataDirectory().getAbsolutePath();
String memoryAvaliSpace= Formatter.formatFileSize(
this,getAvailSpace(path));
String sdPath=Environment.getExternalStorageDirectory().getAbsolutePath();
String sdAvaliSpace= Formatter.formatFileSize(
this,getAvailSpace(sdPath));
private long getAvailSpace(String path) {
StatFs statfs=
new StatFs(path);
long count=statfs.getAvailableBlocks();
long size=statfs.getBlockSize();
return count*size;
}
转载请注明原文地址: https://ju.6miu.com/read-1294984.html