title: phonegap/cordova filewriter and reader not working
body: <p>I'm developing an Android app on eclipse with cordova 2.2.0. It seems that gets Phonegap's file API, but can't read or write on the files.</p>
  
  <p>I've copied the script from xcode, where I'm finished with the app for iOS, and it works. </p>
  
  <p>Here's my script, traced with console outputs:</p>
  
  <pre><code>window.onload = function (){
      console.log('1: onload');
      document.addEventListener("deviceready", getSettings, false);
  }
  function getSettings(){
      console.log('2: getSettings()');
      fileSys('settings.txt', 'getContent', null);
      //fileSys('settings.txt', 'replaceContent', 'new settings');
  }
  function fileSys(fileName, action, data){
      console.log('3: fileSys - '+fileName+' - '+action);
      var directory = (fileName == 'sidur') ? 'appin/sidur':'appin';
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
      function gotFS(fileSystem) {
      console.log('4: Got file system, get directory...');
      fileSystem.root.getDirectory(directory, {create: true}, gotDir, fail);
      }
      function gotDir(dirEntry) {
          console.log('5: Got directory. Get file...');
          dirEntry.getFile(fileName, {create: true, exclusive: false}, gotFileEntry, fail);
      }
      function gotFileEntry(fileEntry){
          console.log('6: got file. Perform action: '+action+'...');
          if(action == 'getContent') readAsText(fileEntry);
          if(action == 'replaceContent') fileEntry.createWriter(gotFileWriter, fail);
      }
      function gotFileWriter(writer){
          console.log('7: got file writer...');
          writer.write(data); //function variable of fileSys();
          writer.onwriteend = function(evt) {
          console.log('8: file written');
          };
      }
      function readAsText(file) {
          console.log('7: read as text...');
          var reader = new FileReader();
          reader.readAsText(file);
          reader.onloadend = function(evt) {
              console.log('9: done reading file');
              init(evt.target.result);
          }
      }
      function fail(error){
          console.log('fail: '+error.code);
  
      }
  }
  function init(settings){
      console.log('Init. Settings: '+JSON.stringify(settings));
  }
  </code></pre>
  
  <p>Running this script gives the following console output:</p>
  
  <ul>
  <li>1: onload</li>
  <li>2: getSettings()</li>
  <li>3: fileSys - settings.txt - getContent</li>
  <li>4: Got file system, get directory...</li>
  <li>5: Got directory. Get file...</li>
  <li>6: got file. Perform action: getContent...</li>
  <li>7: read as text...</li>
  </ul>
  
  <p>And there it stops. reader.onloadend is never called, and no error is specified. If I run again, but instead call fileSys('settings.txt', 'replaceContent', 'new settings'); and outcomment the other call to fileSys, the console outputs: </p>
  
  <ul>
  <li>1: onload</li>
  <li>2: getSettings()</li>
  <li>3: fileSys - settings.txt - replaceContent</li>
  <li>4: Got file system, get directory...</li>
  <li>5: Got directory. Get file...</li>
  <li>6: got file. Perform action: replaceContent...</li>
  <li>7: got file writer...</li>
  </ul>
  
  <p>I have:</p>
  
  <ul>
  <li>set the correct permissions/plugins in res/config.xml and in the android manifest.xml</li>
  <li>Verified that the Phonegap API is included and working (with notifications)</li>
  </ul>
  
  <p>I am new to app development as well as eclipse, so this could very well be some basic thing I've missed. Any suggestions and pointers are most welcome.</p>