get ROM Size - Android android.os

Android examples for android.os:StatFs

Description

get ROM Size

Demo Code

import java.io.File;

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

public class Main {

  public static long getROMSize(boolean all) {
    long blocks = 0;
    File path = Environment.getDataDirectory();
    StatFs sf = new StatFs(path.getPath());
    long blockSize = sf.getBlockSize();
    if (all) {/*w  w  w.j  a v  a 2  s  .com*/
      blocks = sf.getBlockCount();
    } else {
      blocks = sf.getAvailableBlocks();
    }
    return (blocks * blockSize) / 1024 / 1024;
  }

}

Related Tutorials