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