Android SDCard Check getAvailableStorageSize(File dir)

Here you can find the source of getAvailableStorageSize(File dir)

Description

get Available Storage Size

Declaration

public static long getAvailableStorageSize(File dir) 

Method Source Code

//package com.java2s;
import android.os.StatFs;

import java.io.*;

public class Main {
    public static long getAvailableStorageSize(File dir) {
        long size = -1;
        if (dir != null && dir.exists() && dir.isDirectory()) {
            try {
                StatFs stat = new StatFs(dir.getPath());
                size = (long) stat.getBlockSize()
                        * stat.getAvailableBlocks();
            } catch (Exception e) {
                e.printStackTrace();/*  ww w .  j  a  v  a  2s  .  co m*/
            }
        }
        return size;
    }
}

Related

  1. isExtStorageWritable()
  2. isExternalStorageWritable()
  3. isExternalStoragePresent()
  4. getAlbumStorageDirectory(String albumName)
  5. getExtStoragePubDir(String dirName, String dirType)
  6. getDatafilesStorageDirectory(Context context)