Java tutorial
//package com.java2s; import android.annotation.SuppressLint; import android.content.Context; import android.os.Build; import android.os.Environment; import android.os.StatFs; public class Main { @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static boolean getSDCardRemainCanWrite(Context context, long remainSize) { String path = getSDCardDataPath(context); StatFs statFS = new StatFs(path); long blockSize = 0L; if (getSDKInt() >= 18) { blockSize = statFS.getBlockCountLong(); } else { blockSize = statFS.getBlockSize(); } long availableBlock = 0L; if (getSDKInt() >= 18) { availableBlock = statFS.getAvailableBlocksLong(); } else { availableBlock = statFS.getAvailableBlocks(); } long size = blockSize * availableBlock; if (size > remainSize) { return true; } return false; } public static String getSDCardDataPath(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return Environment.getExternalStorageDirectory().getAbsolutePath(); } return null; } public static int getSDKInt() { return Build.VERSION.SDK_INT; } }