title: Singleton class returning NullPointerException
body: <p>I have a Singleton class. When I try to access the instance of the class I get a NullPointerException.</p>
  
  <p>Here is my code:-</p>
  
  <p>Logout.java</p>
  
  <pre><code>private static Logout instance;
  public Logout() {
  
      instance = this;
  }
  public static Logout getInstance() {
      return instance;
  }
  public void clearApplicationData() 
       {
         File cache = getCacheDir();
         File appDir = new File(cache.getParent());
          if (appDir.exists()) {
          String[] children = appDir.list();
          for (String s : children) {
              if (!s.equals("lib")) {
                  deleteDir(new File(appDir, s));
                  Log.i("TAG", "**************** File /data/data/APP_PACKAGE/" + s + " DELETED *******************");
              }
          }
      }
  }
   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>
  
  <p>Main.java</p>
  
  <pre><code>Logout.getInstance.clearapplicationData();  //NullPointerException here
  </code></pre>
  
  <p>Can anyone point out what I am doing wrong here?</p>