title: Delete files from application directory folder in Android?
body: <p>I created folder inside application directory.</p>
  
  <pre><code>File dir = new File(getActivity().getFilesDir().getParent() + File.separator + "Image directory");
  </code></pre>
  
  <p>in that again i created folder for specify contents </p>
  
  <pre><code>File dir1 = new File(getActivity().getFilesDir().getParent() + File.separator + "Image directory" + File.separator+ "Image 1");
  </code></pre>
  
  <p>Inside that I am going to storage images. Images are stored and accessed.</p>
  
  <p>I want to delete all images which are stored at dir1 location.</p>
  
  <p>I tried</p>
  
  <pre><code>if(dir1.isDirectory())
  {
      for (int j = 0; j &lt; dir1.length; j++)
      {
          File file = new File(dir1, dir1[j]);
          //file.canExecute();
          file.delete(); 
      }
  }
  </code></pre>
  
  <p><code>file.delete();</code>  returns false each time.</p>
  
  <p>I added permissions in manifest</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
   &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
   &lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/&gt;
  </code></pre>