This question is possibly a duplicate but I have gone through all the answers and noticed that they won't be working anymore.
private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}
Method-1 failed
private static boolean checkRootMethod2() {
String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
"/system/bin/failsafe/su", "/data/local/su" };
for (String path : paths) {
if (new File(path).exists()) return true;
}
return false;
}
Method 2 also failed because "SuperSu" is not system app anymore it can be uninstall and su file is now present on separate folder SU/bin/su
private static boolean checkRootMethod3() {
Process process = null;
try {
process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
if (in.readLine() != null) return true;
return false;
} catch (Throwable t) {
return false;
} finally {
if (process != null) process.destroy();
}
}
method 3 also failed because there is no "which" file on android devices nowadays
RootTools.isavailable();
also failed
My question is can I detect device rooted by checking whether the su file is inside the Su/bin/su folder? Is this the right way to detect rooted device?