Reputation: 13998
I am trying to create a cpu usage monitoring application and I was wondering how I can read proc/stat from Android application.
Thanks in advance..
Upvotes: 0
Views: 4003
Reputation: 16397
Just read it like any other file...
try {
BufferedReader mounts = new BufferedReader(new FileReader("/proc/stat"));
String line;
while ((line = mounts.readLine()) != null) {
// do some processing here
}
}
catch (FileNotFoundException e) {
Log.d(TAG, "Cannot find /proc/stat...");
}
catch (IOException e) {
Log.d(TAG, "Ran into problems reading /proc/stat...");
}
Upvotes: 3