How can i check if android device is rooted or not? I am using the following code:
Process proc = Runtime.getRuntime ().exec ("su");
and when I run it on a device I got following exception.
Causes by:Permission denied
But running on an emulator does not give any exception.
I am using another way to check. Entering adb shell
in the commend line for emulator returns #, but for device writing adb shell
gives the following error:
shell@android:/ $ su
su
/system/bin/sh: su: not found
127|shell@android:/ $
So how can I check if device is rooted or not.
Thanks in Advance.
Here's how to check if the phone is rooted via the Settings app: Step 1: Open Settings, and click the "About phone" > "Status information" > "Phone status" option. Step 2: If your device has an official phone status, it is not rooted. Instead, if there is a custom tag on the screen, your phone has been rooted.
A rooted device is an Android gadget that has been jailbroken to install unapproved apps, update OS, delete unwanted apps, underclock or overclock the processor, replace firmware and customize anything else. For an average mobile user, rooting a smartphone can be a sophisticated and scary process.
#6) SuperSU Best for the root access of Android devices for free. SuperSU is a great root access management tool developed for Android devices. The app is root-only software that helps you manage app permissions on your rooted device. Using the app allows you to protect your device from harmful apps after rooting.
I use this class:
private void CheckRoot()
{
Process p;
try {
// Preform su to get root privledges
p = Runtime.getRuntime().exec("su");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("echo \"Do I have root?\" >/data/LandeRootCheck.txt\n");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
try {
p.waitFor();
if (p.exitValue() == 0) {
// TODO Code to run on success
this.IsRoot=true;
}
else {
// TODO Code to run on unsuccessful
this.IsRoot=false;
}
} catch (InterruptedException e) {
// TODO Code to run in interrupted exception
toastMessage("not root");
}
} catch (IOException e) {
// TODO Code to run in input/output exception
toastMessage("not root");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With