title: Android- performing su commands programatically does not work
body: <p>I need my app to perform some <code>su</code> commands programatically (phone is rooted).</p>
  
  <p>When done using adb, the commands work.</p>
  
  <p>For instance:
  <code>su -c "mkdir /sdcard/testdir"</code> creates a directory called "testdir" in /sdcard.</p>
  
  <p>When I call:</p>
  
  <pre><code>    p = Runtime.getRuntime().exec("su -c \"mkdir /sdcard/testdir\"");
      p.waitFor();
  </code></pre>
  
  <p>It just moves on and no change happens.</p>
  
  <p>I tried reading the input:</p>
  
  <pre><code>DataInputStream dis = new DataInputStream(p.getInputStream());
      while((temp = dis.readLine())!=null)
          Log.d(ctx.TAG,"shell:"+temp);
  </code></pre>
  
  <p>But it reports nothing (loop does 0 iterations).</p>
  
  <p>Has anyone ever faced this issue before? How can it be solved?
  Needless to day, non-su commands do work programatically with this method.</p>
  
  <p>Note: I gave <code>mkdir</code> as an example (I know it doesn't necessarily require su). I need a lot of varied commands to be performed under <code>su</code></p>
  
  <p>Thank you!</p>
  
  <p>EDIT: when I call <code>su -c "id"</code> programatically, there's output that uid=0.</p>