Possible Duplicate:
Determine if running on a rooted device
I'm creating an Android application and I want to know if my application is running on a rooted device.
I did the digging on Google, but could not come up with even one solid solution.
Similar questions have been asked before on stackoverflow, but without any solution. The solutions provided in these links do not work on my device. Even Runtime.exec("su") does not work.
Determining if an Android device is rooted programatically?
Determine if running on a rooted device
Is there a way to find out the device is rooted? If we cannot do it, how is that Google can find if the device is rooted?
When I do Runtime.exec("su") I am getting exception 10-15 18:36:36.445: W/System.err(668): java.io.IOException: Error running exec(). Commands: [su] Working Directory: null Environment: null
public static boolean isDeviceRooted_BySu() {
try {
Log.d("BySu", "BySu");
Process p = Runtime.getRuntime().exec("su");
return true;
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
I have checked from ADB shell, and It gives me a "#" prompt, So I can be sure that the device is at least Shell rooted. Given that it is shell rooted, then the solutions provided on the Determine if running on a rooted device should at least work, but that does not work either.