Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.os.StatFs;

public class Main {
    public static long getFreeSpace(String dir) {
        StatFs state = null;
        try {
            state = new StatFs(dir);
            long blockSize = state.getBlockSize();
            long availableCount = state.getAvailableBlocks();
            long free = availableCount * blockSize;
            if (free > 0) {
                return free;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}