title: Clear App Data in android and iOS in react-native project?
body: <p>HI I know similar questions such as <a href="https://stackoverflow.com/questions/6134103/clear-applications-data-programmatically">this</a> is asked before. The mentioned solutions aren't helpful.</p>
  
  <ol>
  <li><p>Tried this ` </p>
  
  <pre><code>  File cache = getReactApplicationContext().getCacheDir();
      File appDir = new File(cache.getParent());
      if (appDir.exists()) {
          String[] test =  cache.list();
          Log.d("before", Arrays.toString(test));
          for (String s : test) {
              //if (s.contains(".pdf") || s.contains(".mp4")) {
                  deleteDir(new File(cache, s));
                  Log.i("TAG", "**************** File /data/data/APP_PACKAGE/" + s + " DELETED *******************");
             // }
          }
          Log.d("After delete", Arrays.toString(cache.list()));
      }
  
  public static boolean deleteDir(File dir)
  {
      if (dir != null &amp;&amp; dir.isDirectory()) {
          String[] children = dir.list();
          for (int i = 0; i &lt; children.length; i++) {
              boolean success = deleteDir(new File(dir, children[i]));
              if (!success) {
                  return false;
              }
          }
      }
      return dir.delete();
  }
  </code></pre></li>
  </ol>
  
  <p>` but nothing happened </p>
  
  <ol start="2">
  <li><p>Tried this ` </p>
  
  <pre><code> try{
   if (Build.VERSION_CODES.KITKAT &lt;= Build.VERSION.SDK_INT) {
              ((ActivityManager) getReactApplicationContext().getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData(); // note: it has a return value!
          } else {
              String packageName = getCurrentActivity().getPackageName();
              Runtime runtime = Runtime.getRuntime();
              runtime.exec("pm clear " + packageName);
  
  
     } 
    } catch(error){console.log("error"+error)}`
  </code></pre></li>
  </ol>
  
  <p>got warning in console  Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. app is exited which is not encouraged.
  I need to show the login page after cleaning data.</p>
  
  <p>Any Insights ???</p>