Can't run the "su" program on the root device
I have an embedded Android N phone (AOSP build). I am trying to root my application but it keeps getting denied permission. Here's what I'm trying:
java.lang.Process p = runtime.exec("su");
DataOutputStream commandLine = new DataOutputStream(p.getOutputStream());
commandLine.writeBytes("rm /data/local/tmp/testfile\n");
commandLine.flush();
p.waitFor();
However, it keeps failing with the error:
W/System.err: java.io.IOException: Cannot run program "su": error=13, Permission denied
W/System.err: at java.lang.ProcessBuilder.start(ProcessBuilder.java:983)
W/System.err: at java.lang.Runtime.exec(Runtime.java:691)
W/System.err: at java.lang.Runtime.exec(Runtime.java:524)
W/System.err: at java.lang.Runtime.exec(Runtime.java:421)
W/System.err: at MainActivity$2.onClick(MainActivity.java:104)
I also added android.permission.ACCESS_SUPERUSER
to my manifest, but that doesn't seem to make any difference.
+3
source to share