title: how to delete a folder in Android
body: <p>I am having trouble deleting folders.</p>
  
  <p>I made folders and folders.delete returns false. Why?</p>
  
  <p>I also tried this below. This returns false and the folder doesn't get erased. Why?</p>
  
  <pre><code>public static boolean deleteDirectory(File path) {
              if( path.exists() ) {
                File[] files = path.listFiles();
                if (files == null) {
                    return true;
                }
                for(int i=0; i&lt;files.length; i++) {
                   if(files[i].isDirectory()) {
                     deleteDirectory(files[i]);
                   }
                   else {
                     files[i].delete();
                   }
                }
              }
              return( path.delete() );
            }
  </code></pre>