获取手机内部可用空间大小 :
public long getInternalStorageAvailableSpace()
{
long ret=0;
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
ret = availableBlocks * blockSize;
return ret;
}
获取手机外部可用空间大小:
public long getSDCardAvailableSpace()
{
long ret=0;
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
ret = availableBlocks * blockSize;
return ret;
}