ANDROID 获取SD卡剩余容量

String sdcard = Environment.getExternalStorageDirectory().getPath(); 

File file = new File(sdcard); 

StatFs statFs = new StatFs(file.getPath()); 

int availableSpare = (int) (statFs.getBlockSize()*((long)statFs.getAvailableBlocks()-4)); 

 需要import android.os.StatFs;

你可能感兴趣的:(android)