To get the external SD card's available "free" space to show a number which agrees with the Menu->Settings->SD card and phone storage's number, use the following code:
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
double sdAvailSize = (double)stat.getAvailableBlocks()
* (double)stat.getBlockSize();
//One binary gigabyte equals 1,073,741,824 bytes.
double gigaAvailable = sdAvailSize / 1073741824;
Relevant documentation: http://developer.android.com/reference/android/os/StatFs.html
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…