I want to execute the “adb logcat -d time > pathoffile\log.txt &” in my java code.
I want to create my log.txt in my device.
I wrote this code to do this.
ArrayList<String> commandLine = new ArrayList<String>();
commandLine.add("logcat");
commandLine.add("-d");
commandLine.add("time");
commandLine.add(">");
commandLine.add(getApplicationContext().getFilesDir()
// + "/log.txt"); //already created the file at specified location.
//commandLine.add("&");
Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0]));
The above code not throwing any error , but my file (log.txt) is not updating with the log statements..
please help me in this how to do this, pl. suggest if there’s any alternative to do this..
thanks.
Try
-foption instead:Note that
>is io redirection feature of shell. It has no effect when used withexec()function.