get Local Storage Space via StatFs - Android Hardware

Android examples for Hardware:Storage

Description

get Local Storage Space via StatFs

Demo Code


//package com.java2s;

import android.os.StatFs;

public class Main {
    public static float getLocalStorageSpace() {
        float space = 0;
        try {//from   w  ww .j a  v  a 2  s.co m
            StatFs stat = new StatFs("/data/");
            space = stat.getAvailableBlocks() * (float) stat.getBlockSize();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return space;
    }
}

Related Tutorials