I am trying to run 3 different commands through my app but only the first one is getting executed. here's the code.
Process process = Runtime.getRuntime().exec("su");
process = Runtime.getRuntime().exec("mount -o remount,rw /system");
process = Runtime.getRuntime().exec("cp /sdcard/hosts /system/etc");
I get the root access but after that nothing else happens.
EDIT: I tried this code but this also executes only su comand
String[] commands = {"mount -o remount,rw /system", "cp /sdcard/hosts /system/etc"};
Process p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
for (String tmpCmd : commands) {
os.writeBytes(tmpCmd+"\n");
}
os.writeBytes("exit\n");
os.flush();
EDIT: This works but only one command at time, i'll have to make a button for every command.
String[] hin1 = { "su", "-c","cp /sdcard/Mediafire/hosts /system/etc/" };
try {
Runtime.getRuntime().exec(hin1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}