get Available Internal Storage - Android App

Android examples for App:Local Storage

Description

get Available Internal Storage

Demo Code


//package com.java2s;

import android.os.Environment;
import android.os.StatFs;
import java.io.File;

public class Main {
    public static long getAvailableInternalStorage() {
        File file = Environment.getDataDirectory();
        if (file != null && file.exists()) {
            StatFs sdFs = new StatFs(file.getPath());
            if (sdFs != null) {
                long sdBlockSize = sdFs.getBlockSize();
                long sdAvailCount = sdFs.getAvailableBlocks();
                return sdAvailCount * sdBlockSize;
            }/*from  w  w  w  . j av  a 2  s.c o  m*/
        }
        return 0;
    }
}

Related Tutorials