Android Shell Run runAsRoot(String[] commands)

Here you can find the source of runAsRoot(String[] commands)

Description

run As Root

Declaration

public static void runAsRoot(String[] commands) throws IOException,
            InterruptedException 

Method Source Code

//package com.java2s;

import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    public static void runAsRoot(String[] commands) throws IOException,
            InterruptedException {
        Process p = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(p.getOutputStream());
        for (String cmd : commands) {
            os.writeBytes(cmd + "\n");
        }//from www.  jav  a 2s  .co m
        os.writeBytes("exit\n");
        os.flush();
        os.close();
        p.waitFor();
    }
}

Related

  1. executeCommand(String command)
  2. normalShell(String normalCommand)
  3. runSimpleCommand(String command, String directory)
  4. doShellCommand(String[] cmds, StringBuilder log, boolean runAsRoot, boolean waitFor)
  5. findProcessId(String command)
  6. findProcessIdWithPidOf(String command)