public void uninstallApp(String packageName){
try {
String[] command = new String[4];
command[0] = "su";
command[1] = "mount -o remount,rw /system";
command[2] = "rm " + packageName;
command[3] = "reboot";
Runtime run = Runtime.getRuntime();
run.exec(command);
Log.d("DELETED", packageName);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e("ERROR ON DELETE", e.getMessage());
}
}
That's my code. This method receives an apk's path, what i need to do is execute those commands but without loosing permissions. I mean, if i execute "su" in one process and then "mount" in other process. "mount" won't have "su" access. So i need to execute all those commands in a single process. And that's not working. :\
}before thecatch. Please make sure that your posted code is valid.execand use aProcessBuilderto create the process.