• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Do Android phones have su folder by default? Implement root detection using Rootbeer

Calvert Wong

Newbie
Jun 23, 2013
11
3
There are a few questions related to each other and I couldn't type it out in the title.

Do Android phones and emulators have su folder by default? From what I have seen, Android Studio emulator has the su folder but not my Xiaomi actual phone. I am asking this is because I am trying to implement the root detection feature to an app and I have downloaded the Root Check Basic app to play around with.

I am trying out the Rootbeer library and it says my emulator is rooted because there is a su folder in it but Root Check Basic says it is not rooted. Are there any manufacturer out there included su folder in Android phones?
 
There are a few questions related to each other and I couldn't type it out in the title.

Do Android phones and emulators have su folder by default? From what I have seen, Android Studio emulator has the su folder but not my Xiaomi actual phone. I am asking this is because I am trying to implement the root detection feature to an app and I have downloaded the Root Check Basic app to play around with.

I am trying out the Rootbeer library and it says my emulator is rooted because there is a su folder in it but Root Check Basic says it is not rooted. Are there any manufacturer out there included su folder in Android phones?
android studio is different then your phone. so yes since android studio is for app development of course you will have an su folder. your phone, unless it is rooted will not have an su folder( even if it is rooted will nopt actually have an su folder). a rooted phone will have access to root, but it will not have a specific folder called su.
 
Upvote 0
android studio is different then your phone. so yes since android studio is for app development of course you will have an su folder. your phone, unless it is rooted will not have an su folder( even if it is rooted will nopt actually have an su folder). a rooted phone will have access to root, but it will not have a specific folder called su.
Just to clarify you mean detecting for the existence of the su folder won't 100% tell the phone is rooted? I am trying find better ways to determine if a phone is rooted and there are so many things that can check and prevent it from being detected.
 
Upvote 0
correct. at least with my phones that i have rooted never had an su folder. so just by searching for that does not necessarily mean it is rooted.

there are ways to determine if the phone is rooted. you can download the superuser app, it will tell you if you have root permission or not. you can download a terminal emulator on your phone and type "su"........this might be something you might be interested.

also some apps that members here posted:
https://androidforums.com/threads/rootsu-root-checker.1290087/
 
  • Like
Reactions: GameTheory
Upvote 0
I am trying out the Rootbeer library and it says my emulator is rooted because there is a su folder in it but Root Check Basic says it is not rooted.

It seems the Rootbear library is giving a false positive due to its' aggressive root check. On the other hand, Root Check Basic is probably just searching for the su binary file which wouldn't be present on a non rooted device.

The su binary location can vary depending on root method. For magisk which is the most common root method, you can find the binary in the "/sbin" directory which is just a symlink to the magisk binary.

One way to search for root with java is as follows...

Java:
private static boolean checkSU() {
  String[] paths = {
    "/su/bin/su",
    "/system/xbin/su",
    "/su/xbin/su",
    "/sbin/su",
    "/system/bin/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;
}

I do recommend combining this with other methods.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones