Skip to content

Instantly share code, notes, and snippets.

@koush
Created August 7, 2010 17:00
Show Gist options
  • Save koush/512983 to your computer and use it in GitHub Desktop.
Save koush/512983 to your computer and use it in GitHub Desktop.
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;
}
public static int runSuCommand(Context context, String command) throws IOException, InterruptedException
{
return runSuCommandAsync(context, command).waitFor();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment