import android.os.Build;
import java.io.File;
public class UtilCheckIcon {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
}
private static boolean checkRootMethod1() {
String str = Build.TAGS;
return str != null && str.contains("test-keys");
}
private static boolean checkRootMethod2() {
String[] strArr = {"/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", "/su/bin/su"};
for (int i = 0; i < 10; i++) {
if (new File(strArr[i]).exists()) {
return true;
}
}
return false;
}
private static boolean checkRootMethod3() {
return new File("/system/app/Superuser.apk").exists();
}
Check if android device is rooted programmatically
