I want to be able to write to a file that is system and that the only way to do it is with root permissions (I have them but it does not even work).
My code
Process proc = Runtime.getRuntime().exec(command);
Toast.makeText(this, "Si", Toast.LENGTH_LONG).show();
OutputStream os = proc.getOutputStream();
byte[] chunk = new byte[CHUNK_SIZE];
int bytesLeidos = 0;
while ( (bytesLeidos = is.read(chunk)) > 0) {
os.write(chunk, 0, bytesLeidos);
}
os.close();
I explain my code: all it does is request root permissions and open the contents of the file and then try to write to it using conventional Java methods.
My command
The command I use is su -c cat ruta de archivo