title: How to restrict my android app in rooted device which contain magisk app?
body: <p>I am working on an android app. I want to save my app from rooted devices. I am successfully restricting my app with rooted devices, but one rooted device has magisk app, so with the help of this magis app, user is able to open my app in rooted device also. can any body help me in this? Thanks in advance.</p>
  
  <p>my code is </p>
  
  <p>private static boolean checkRootMethod1() {
          String buildTags = Build.TAGS;
          return buildTags != null &amp;&amp; buildTags.contains("test-keys");
      }</p>
  
  <pre><code>private static boolean checkRootMethod2() {
      String[] paths = {"/system/apn/which sup/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su",
              "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/.ext/.su",
              "/system/bin/failsafe/su", "/data/local/su", "/system/xbin/mu", "/su/bin/su", "/system/usr/we-need-root/su-backup"};
      for (String path : paths) {
          if (new File(path).exists()) return true;
      }
      return false;
  }
  
  private static boolean checkRootMethod3() {
      File file = Environment.getDataDirectory();
      return file != null &amp;&amp; file.canWrite();
  }
  
  private static boolean checkRootMethod4() {
      File file = new File("/system/bin/");
      return file != null &amp;&amp; file.canWrite();
  }
  
  private static  boolean checkRootMethod5() {
      return new File("/system/app/Superuser.apk").exists();
  }
  </code></pre>