Get free Space On External Storage - Android android.os

Android examples for android.os:Environment

Description

Get free Space On External Storage

Demo Code

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.lemon.assist.Check;
import android.lemon.config.BaseConfig;
import android.os.Environment;
import android.os.StatFs;


public class Main{


    @SuppressWarnings("deprecation")
    public static int freeSpaceOnSD() {
        StatFs stat = new StatFs(Environment.getExternalStorageDirectory()
                .getPath());//w  w  w.j  av a 2 s.c om
        double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat
                .getBlockSize()) / 1024 * 1024;
        return (int) sdFreeMB;
    }

}

Related Tutorials