title: Check to see whether root was granted?
body: <p>I have set up my app to execute the <code>su</code> command using this code:</p>
  
  <pre><code>try {
              Runtime.getRuntime().exec("su");
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              altDialog.setTitle("No Root");
              altDialog
                      .setMessage("I am afraid I have been unable to execute the su binary. Please check your root status.");
              altDialog.setCancelable(false);
              altDialog.setButton("Exit App",
                      new DialogInterface.OnClickListener() {
  
                          @Override
                          public void onClick(DialogInterface arg0, int arg1) {
                              // TODO Auto-generated method stub
                              Log.e("Android .img Flasher",
                                      "Exiting due to root error");
                              finish();
                          }
                      });
          }
  </code></pre>
  
  <p>This catches if the <code>su</code> command doesn't exist (I believe), but not if root was actually granted.</p>
  
  <p>How would I be able to check if root was actually granted?</p>
  
  <p>On a side note, how would I be able to store the output of a command using the <code>Runtime.getRuntime.exec()</code> command?</p>