要运行root命令,你必须使用以下格式:
public void RunAsRoot(String[] cmds){ Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd+"n"); } os.writeBytes("exitn"); os.flush();}在其中传递字符串数组,每个字符串都是需要执行的命令。例如:
String[] commands = {"sysrw", "rm /data/local/bootanimation.zip", "sysro"};


