Search code examples
androidroot

Is it possible to run an android app as root


I know it's possible to run commands as root with Runtime.getRuntime().exec("su -c ps");

But what about using File() to read on /data/user/0/...... is it possible? Maybe with Magisk?


Solution

  • Inside a JVM there is no root user, therefore it is impossible. This might explain it better: https://android.stackexchange.com/questions/133466/how-does-supersu-provide-root-privilege

    And I barely use the term "impossible", but in this case only the underlying Linux OS may provide a root shell - also C/C++ native assembly could escalate privileges, as it is running on the actual OS. Runtime.getRuntime().exec() also just executes in a shell (which is not a part of the JVM).