title: Deleting files from a folder - android
body: <p>I have a folder which contains some files that I want to deleted after processing them. The files have the extension <code>.FIR</code> After some googling I found a recursive method that I modified a bit:</p>
  
  <pre><code>void delete(File f) throws IOException {
        if (f.isDirectory()) {
          for (File c : f.listFiles())
              if(f.listFiles().toString().contains(".FIR"))
                  delete(c);
        }
        if (!f.delete())
          throw new FileNotFoundException("Failed to delete file: " + f);
      }
  </code></pre>
  
  <p>This function will throw an IOException telling me:</p>
  
  <pre><code>07-31 11:02:31.885: E/DELETE:(5694): Failed to delete file: /mnt/sdcard/ExtractedFiles
  </code></pre>
  
  <p>The folder has been set to <code>RW</code> operations. And in my manifest file:</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>I couldn't find another permission that sounded something like <code>MODIFY_FILES</code></p>
  
  <p>Any ideas? </p>