Java tutorial
//package com.java2s; import java.io.DataOutputStream; import android.content.Context; import android.util.Log; public class Main { public static boolean tempRunRootCommand(Context context, String command) { Process process = null; DataOutputStream os = null; try { process = Runtime.getRuntime().exec("su1"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor(); } catch (Exception e) { Log.d("*** DEBUG ***", "Error - " + e.getMessage()); return false; } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { } } return true; } }