title: Download file with PhoneGap and use within AngularJS
body: <p>I´m building a PhoneGap/Cordova app with AngularJS. I spent a huge amount of time on finding out how to successfully download a remote file to the device. Here´s my code:</p>
  
  <pre><code>download: function() {
      console.log('start download');
      var remoteFile = "http://remoteserver.domain";
      var localFileName = "file.json";
  
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
          fileSystem.root.getFile(localFileName, {create: true}, function(fileEntry) {
              var localPath = fileEntry.toURL();
              var ft = new FileTransfer();
              ft.download(remoteFile,
                  localPath, 
                  function(entry){console.log(entry)}, 
                  function(error){console.log(error.code)}
              );
          }, function(error){console.log(error.code)});
      }, function(error){console.log(error.code)});
  }
  </code></pre>
  
  <p>For iOS, the native path of the file returned by the FileSystem API is the Documents folder of my app. But because I´m using AngularJS and it runs within the www folder inside the Appname.app folder, I have no clue how I can access that file from AngularJS so that it will also work out of the box with Android and other OS supported by PhoneGap.</p>
  
  <p>So what I want to do is either tell the File API to save the file inside the <em>Appname.app/www</em> folder, or tell AngularJS to use <em>../Documents/</em> folder, but without being platform-specific. Maybe there´s a completely different solution I could use?</p>