Android examples for Android OS:Shell Command
Root Shell Command
//package com.java2s; import java.io.DataOutputStream; import android.util.Log; public class Main { public static boolean RootCommand(String command) { Process process = null;//from ww w. ja va2 s. c o m DataOutputStream os = null; try { process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor(); } catch (Exception e) { Log.d("*** DEBUG ***", "ROOT REE" + e.getMessage()); return false; } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { // nothing } } Log.d("*** DEBUG ***", "Root SUC "); return true; } }