Android 应用程序执行Shell命令

Ref : stackoverflow.com/questions/9298606/running-chmod-from-my-application-doesnt-work-after-running-su


Process suProcess = Runtime.getRuntime().exec("su");

    DataOutputStream os = 
        new DataOutputStream(suProcess.getOutputStream());

   **strong text**
    for (String Command : /*your commands*/)
    {
      os.writeBytes(Command + "\n");
      os.flush();
    }

    os.writeBytes("exit\n");
    os.flush();

你可能感兴趣的:(Android 应用程序执行Shell命令)