I found out that there\'s so many apps out there which required root access.
How were they able to create those apps? Where did they found all the resource? Is ther
Use this function and use it anywhere of your project
public static void sudo(String... strings) {
try {
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
for (String s : strings) {
outputStream.writeBytes(s + "\n");
outputStream.flush();
}
outputStream.writeBytes("exit\n");
outputStream.flush();
try {
su.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Usage of the above function and use it any type of shell commands with root users
sudo("iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080");