Java tutorial
//package com.java2s; import java.io.File; import android.annotation.SuppressLint; import android.os.Environment; import android.os.StatFs; public class Main { @SuppressLint("NewApi") public static long getSDCardAvailableSize() { if (isSDCardEnable()) { StatFs statFs = new StatFs( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator); if (android.os.Build.VERSION.SDK_INT < 18) { int blockSize = statFs.getBlockSize(); int blockCount = statFs.getAvailableBlocks(); return blockCount * blockSize; } else { long blockSize = statFs.getBlockSizeLong(); long blockCount = statFs.getAvailableBlocksLong(); return blockCount * blockSize; } } return -1; } public static boolean isSDCardEnable() { return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); } }