Android SDCard Check enoughSpaceOnPhone(long updateSize)

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

Description

enough Space On Phone

License

Apache License

Declaration

public static boolean enoughSpaceOnPhone(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 enoughSpaceOnPhone(long updateSize) {
        return getRealSizeOnPhone() > updateSize;
    }/*from  w  w  w . j  a  va 2 s .  c om*/

    public static long getRealSizeOnPhone() {
        File path = Environment.getDataDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        long realSize = blockSize * availableBlocks;
        return realSize;
    }
}

Related

  1. enoughSpaceOnSdCard(long updateSize)
  2. getRealSizeOnPhone()
  3. getRealSizeOnSdcard()
  4. hasExternalCacheDir()