Here you can find the source of runSuCommandAsync(Context context, String command)
public static Process runSuCommandAsync(Context context, String command) throws IOException
//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 Process runSuCommandAsync(Context context, String command) throws IOException { DataOutputStream fout = new DataOutputStream( context.openFileOutput(SCRIPT_NAME, 0)); fout.writeBytes(command);/*from w w w .ja va2 s.c o m*/ fout.close(); String[] args = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME }; Process proc = Runtime.getRuntime().exec(args); return proc; } }