Android获得内部/外部内存的空闲大小
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount(); long megAvailable = bytesAvailable / 1048576;Log.e("","Available MB : "+megAvailable); File path = Environment.getDataDirectory();StatFs stat2 = new StatFs(path.getPath()); long blockSize = stat2.getBlockSize();long availableBlocks = stat2.getAvailableBlocks(); String format = Formatter.formatFileSize(this, availableBlocks * blockSize);Log.e("","Format : "+format);
11-15 10:27:18.844: E/(25822): Available MB : 757211-15 10:27:18.844: E/(25822): Format : 869MB
1,96GB
慕田峪9158850
相关分类