Is there a way to check if a androind device (tablet or smartphone) is rooted or not
Sometimes when doing some android development I need to root a android device but wanted to be able to test if the device is already tooted before i begin rooting

Dani AI

Generated

As asked: you want a reliable way to tell if a device is already rooted before you attempt to root it. and pointed out that consumer apps can tell you that — which is a fine quick check — but for development or automated checks it helps to use a few deterministic tests and to understand their limits.

A short checklist you can run manually (via ADB) or programmatically:

  • Look for the su binary in common paths (for example /system/xbin/su, /system/bin/su, /data/local/bin/su).
  • Try executing su -c id or use which su to see if su is callable.
  • Check for common root-management packages or Superuser-style APKs.
  • Inspect android.os.Build.TAGS for test-keys as a hint of a custom/system image (see Build.TAGS docs).
  • Check whether /system is mounted writable (a writable system partition strongly implies root or unlocked bootloader).

Small, practical programmatic example (Java) that combines a few heuristics:

public static boolean isDeviceRooted() {
    String tags = android.os.Build.TAGS;
    if (tags != null && tags.contains("test-keys")) return true;

    String[] paths = {"/system/bin/su","/system/xbin/su","/data/local/bin/su","/su/bin/su"};
    for (String p : paths) if (new File(p).exists()) return true;

    return canRunWhichSu();
}

private static boolean canRunWhichSu() {
    try {
        Process p = Runtime.getRuntime().exec(new String[]{"which","su"});
        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        return r.readLine() != null;
    } catch (Exception e) { return false; }
}

Caveats and recommendation: none of these checks is bulletproof. Modern tools (for example Magisk) can hide root, and engineering builds can trigger false positives. For production apps that must detect device integrity, use server-side attestation such as the Play Integrity API rather than relying only on local heuristics (Play Integrity API, Magisk repo for hiding techniques, and OWASP MSTG for testing guidance).

Recommended Answers

All 2 Replies

Well, try heading yourself over to the Google PlayStore and download the "Root Checker" application available over the store. It will tell you wether you are a rooted user or not !

There're alot of root checker software on playstore. It's free.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.