title: ANDROID: How to gain root access in an Android application?
body: <p>I'm developing my first <code>Android</code> application, and I'm curious if there are any "standard" ways for executing privileged <code>shell</code> commands. I've only been able to find one way to do it, by executing <code>su</code>, and then appending my commands to <code>stdin</code> of the <code>su</code> process.</p>
  
  <pre><code>DataOutputStream pOut = new DataOutputStream(p.getOutputStream());
  DataInputStream pIn = new DataInputStream(p.getInputStream());
  
  String rv = "";
  
  // su must exit before its output can be read
  pOut.writeBytes(cmd + "\nexit\n");
  pOut.flush();
  
  p.waitFor();
  
  while (pIn.available() &gt; 0)
      rv += pIn.readLine() + "\n";
  </code></pre>
  
  <p>I've read about wrapping privileged (<code>superuser</code>) calls up in <code>JNI</code>: is this possible? If so, how would one go about accomplishing it? Other than that, are there any other ways of calling privileged instructions from <code>Java</code>?</p>