Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;
import android.os.Environment;
import android.os.StatFs;

public class Main {

    public static long getSdCardAvailableSize() {
        File sdcardDir = Environment.getExternalStorageDirectory();
        StatFs sf = null;
        try {
            sf = new StatFs(sdcardDir.getPath());
        } catch (Exception e) {
            return 0;
        }
        long blockSize = sf.getBlockSize();
        long availCount = sf.getAvailableBlocks();
        return availCount * blockSize;
    }
}