title: Cordova remove file
body: <p>I have a working app that creates a file.
  I'm looking for a way to remove files from a cordova app after some hours of work. I can't seem to make it work.</p>
  <p>here is the code for creating and deleting files :</p>
  <pre class="lang-js prettyprint-override"><code>    function crea(){
          alert(cordova.file.externalDataDirectory);
      window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) {
              alert(&quot;got main dir&quot;,dir);
              dir.getFile(&quot;log1.txt&quot;, {create:true}, function(file) {
                  alert(&quot;got the file&quot;, file);
                              
              });
          });
              }
  
  
  
          function del(){
      var relativeFilePath = cordova.file.dataDirectory;
      var filename = &quot;log1.txt&quot;; 
      alert(relativeFilePath);
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
        //  alert(fileSystem.root.fullPath);
          fileSystem.root.getFile(relativeFilePath + filename, {create:false}, function(fileEntry){
              fileEntry.remove(function(file){
                  alert(&quot;File removed!&quot;);
              },function(){
                  alert(&quot;error deleting the file &quot; + error.code);
                  });
              },function(){
                  alert(&quot;file does not exist&quot;);
              });
          },function(evt){
              alert(evt.target.error.code);
      });
      
      }
  </code></pre>
  <p>Best Regards.</p>