/**
* 获取手机内部可用空间大小
* @return
*/
static public long getAvailableInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
}
<pre name="code" class="java" style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; color: rgb(57, 57, 57); font-size: 14px; line-height: 21px; background-color: rgb(250, 247, 239);">/**
* 获取手机内部空间大小
* @return
*/
static public long getTotalInternalMemorySize() {
File path = Environment.getDataDirectory();//Gets the Android data directory
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize(); //每个block 占字节数
long totalBlocks = stat.getBlockCount(); //block总数
return totalBlocks * blockSize;
}
其实关键还是在<span style="background-color: rgb(240, 240, 240); font-family: Arial, Helvetica, sans-serif;">StatFs这个类</span>