Here you can find the source of runSuCommand(Context context, String command)
public static int runSuCommand(Context context, String command) throws IOException, InterruptedException
//package com.java2s; import java.io.DataOutputStream; import java.io.IOException; import android.content.Context; public class Main { public final static String SCRIPT_NAME = "surunner.sh"; public static int runSuCommand(Context context, String command) throws IOException, InterruptedException { return runSuCommandAsync(context, command).waitFor(); }/*from w ww .ja v a 2s . c o m*/ public static Process runSuCommandAsync(Context context, String command) throws IOException { DataOutputStream fout = new DataOutputStream( context.openFileOutput(SCRIPT_NAME, 0)); fout.writeBytes(command); fout.close(); String[] args = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME }; Process proc = Runtime.getRuntime().exec(args); return proc; } }