title: Get the output from executed commands through android app
body: <p>I'm performing the following code to execute linux commands in my android application that I'm creating:</p>
  
  <pre><code>public void RunAsRoot(String[] cmds){
              Process p = Runtime.getRuntime().exec("su");
              DataOutputStream os = new DataOutputStream(p.getOutputStream());            
              for (String tmpCmd : cmds) {
                      os.writeBytes(tmpCmd+"\n");
              }           
              os.writeBytes("exit\n");  
              os.flush();
  }
  </code></pre>
  
  <p>I want to know if there is a way to know what the command is returning after it is executing. for example, if I do "ls" I would like to see what the command wold normally output.</p>