I can’t figure out how to flush the Logcat on my Application. Code below
Saving Logcat into File: (this works)
File File_logcat = new File(Environment.getExternalStorageDirectory(),
"log.txt");
try {
Runtime.getRuntime().exec(
"logcat -f " + File_logcat.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
After that save I flush the Logcat with: (this doesn't work)
try {
Runtime.getRuntime().exec(
"logcat --clear"); //Also tested -c or -b all –c
} catch (IOException e) {
e.printStackTrace();
}
I’ve searched for a solution on developer.android.com which says “logcat -b all –c” (or even –c) would flush it but none of them succeed.
Did I miss something?
Thanks @CommonsWare. I just discovered that both code snippets work on a rooted mobile device. So it seems like you can't flush it without permission.