get Device Information from /proc/cpuinfo - Android android.os

Android examples for android.os:CPU

Description

get Device Information from /proc/cpuinfo

Demo Code

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Main {

  public static String[] getDeviceInfo() {
    String str1 = "/proc/cpuinfo";
    String str2 = "";
    String[] cpuInfo = { "", "" };
    String[] arrayOfString;// w w  w  . j  a va 2  s. co  m
    try {
      FileReader fr = new FileReader(str1);
      BufferedReader localBufferedReader = new BufferedReader(fr, 8192);
      str2 = localBufferedReader.readLine();
      arrayOfString = str2.split("\\s+");
      for (int i = 2; i < arrayOfString.length; i++) {
        cpuInfo[0] = cpuInfo[0] + arrayOfString[i] + " ";
      }
      str2 = localBufferedReader.readLine();
      arrayOfString = str2.split("\\s+");
      cpuInfo[1] += arrayOfString[2];
      localBufferedReader.close();
    } catch (IOException e) {
    }
    return cpuInfo;
  }

}

Related Tutorials