Android SDCard Check enoughSpaceOnSdCard(long updateSize)

Here you can find the source of enoughSpaceOnSdCard(long updateSize)

Description

enough Space On Sd Card

License

Apache License

Declaration

public static boolean enoughSpaceOnSdCard(long updateSize) 

Method Source Code

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

import java.io.File;

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

public class Main {
    public static boolean enoughSpaceOnSdCard(long updateSize) {
        String status = Environment.getExternalStorageState();
        if (!status.equals(Environment.MEDIA_MOUNTED))
            return false;
        return (updateSize < getRealSizeOnSdcard());
    }//  www .  j ava2s  .  c  o  m

    public static long getRealSizeOnSdcard() {
        File path = new File(Environment.getExternalStorageDirectory()
                .getAbsolutePath());
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        return availableBlocks * blockSize;
    }
}

Related

  1. enoughSpaceOnPhone(long updateSize)
  2. getRealSizeOnPhone()
  3. getRealSizeOnSdcard()
  4. hasExternalCacheDir()
  5. hasSDCard()