Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Environment;
import android.os.StatFs;

public class Main {
    public static long getSdCardFree() {
        long l = 0L;
        if (Environment.getExternalStorageState().equals("mounted")) {
            StatFs statfs = new StatFs(Environment.getExternalStorageDirectory().getPath());
            l = ((long) statfs.getBlockSize() * (long) statfs.getAvailableBlocks()) / 1024L / 1024L;
        }
        return l;
    }
}