Android SDCard Check getExternalStorageFreeSize()

Here you can find the source of getExternalStorageFreeSize()

Description

Obtain SD card free size.

Return

byte unit of SD card free size.

Declaration

public static long getExternalStorageFreeSize() 

Method Source Code

//package com.java2s;

import android.os.Environment;
import android.os.StatFs;

public class Main {
    /**/*  ww w  .j av a 2  s  .c  o  m*/
     * Obtain SD card free size.
     * 
     * @return byte unit of SD card free size.
     */
    public static long getExternalStorageFreeSize() {
        final StatFs statfs = new StatFs(Environment
                .getExternalStorageDirectory().getAbsolutePath());
        final long availableBlocks = statfs.getAvailableBlocks();
        final long blockSize = statfs.getBlockSize();
        return availableBlocks * blockSize;
    }
}

Related

  1. hasSDCard()
  2. sdCardIsAvailable()
  3. isExternalStorageReadable()
  4. isExternalStorageWritable()
  5. hasMountSDCard()
  6. getExternalStorageTotalSize()
  7. generateLogOnSD(String sBody, String fileName, String folderName)
  8. getDataFilesDir(Context c)
  9. getSDPath()