i'm trying to execute a command with root privileges, i try this(only for example):
Process process = Runtime.getRuntime().exec(new String[]{"su","-c","whoami"});
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
result += line;
Log.d(TAG,"RESULT:"+result);
}
But i need to call it in a cicle with hundred times, so this way is very slow and always is showing a dialog with the message of the root privileges are granted, so how i can create a sigle su
process for write and read consecutively using input and output streams? i know to use both but i dont know how to write and the read the result of the command. Thanks for your help.