You can use this:
Process p = Runtime.getRuntime().exec( "su" );
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes(command1 + "\n");
os.writeBytes(command2 + "\n");
os.writeBytes("exit\n");
os.flush();
As your device is rooted you must use su
command to use commands for rooted devices. I used this solution for restarting our rooted devices from our app and it worked. You can add multiple commands as you see in the code. Hope it works.
Update:
You can use array of commands too. Like this:
Process proc = Runtime.getRuntime()
.exec(new String[] { "su", "-c", command1,command2,"exit" });
proc.waitFor();
or you can use extra exec commands if you need it:
Runtime runtime = Runtime.getRuntime();
runtime.exec("su");
runtime.exec("export LD_LIBRARY_PATH=/vendor/lib:/system");
runtime.exec("pm clear "+PACKAGE_NAME);
This samples will work too, I used them before.