Joshua
Joshua

Reputation: 3

How can I give root permission to my Android app?

I'm trying to use linux command in my app. But I failed to get root permission. Could you please let me know how to get root permission?

 String[] cmd = {"su"};
 String result_process2 = runProcess2(cmd);
 public String runProcess2(String[] cmd) {
    try {
          Process process = Runtime.getRuntime().exec(cmd);

It looks like doesn't work. One thing weird is I found su in /system/xbin, but when I check this directory through ls in app, su file didn't exist there.

Command is

String ls = "ls -al /system/xbin/";
String resultls = runProcess((String)ls);
public String runProcess(String arg) {
    try {
        Process process = Runtime.getRuntime().exec(arg);

Do you know why I couldn't see su file in /system/xbin/ even though it can be found through adb shell in my laptop?

Upvotes: 0

Views: 3004

Answers (1)

Brage Celius
Brage Celius

Reputation: 141

A standard Android device does not have access to root privileges. In order to attain this you will have to root the device. See this link for more information.

As for why you can find the file through the ADB shell and not from within the app is probably that you don't have read access for the file outside the ADB shell.

Upvotes: 1

Related Questions