title: open failed: EROFS (Read-only file system) android phonegap app
body: <p>I'm trying to use a Progress event with PhoneGap for file transfers.</p>
  
  <p>My problem is that every time when I press the download button, the errors below appear. </p>
  
  <p>I found the code under this link and copied it completely: <a href="http://www.raymondcamden.com/2013/05/01/Using-the-Progress-event-in-PhoneGap-file-transfers" rel="nofollow">http://www.raymondcamden.com/2013/05/01/Using-the-Progress-event-in-PhoneGap-file-transfers</a> </p>
  
  <p>Error: 
  10-23 23:55:38.407  24464-24508/? E/FileTransfer﹕ {"target":"//download.mp3","http_status":200,"code":1,"source":"http://archive.org/download/Kansas_Joe_Memphis_Minnie-When_Levee_Breaks/Kansas_Joe_and_Memphis_Minnie-When_the_Levee_Breaks.mp3","exception":"/download.mp3: open failed: EROFS (Read-only file system)"}
      java.io.FileNotFoundException: /download.mp3: open failed: EROFS (Read-only file system)
              at libcore.io.IoBridge.open(IoBridge.java:409)
              at java.io.FileOutputStream.(FileOutputStream.java:88)
              at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329)
              at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310)
              at org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:894)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:841)
       Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
              at libcore.io.Posix.open(Native Method)
              at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
              at libcore.io.IoBridge.open(IoBridge.java:393)
              at java.io.FileOutputStream.(FileOutputStream.java:88)
              at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329)
              at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310)
              at org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:894)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:841)</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;meta name = "format-detection" content = "telephone=no"/&gt;
      &lt;meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/index.css" /&gt;
      &lt;title&gt;FileTransfer Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="content"&gt;
      &lt;p&gt;
          Kansas Joe McCoy and Memphis Minnie – "When The Levee Breaks"
      &lt;/p&gt;
  
      &lt;img src="img/KansasJoeAndMemphisMinnie.jpg"&gt;
  
      &lt;p&gt;
          &lt;button id="startDl"&gt;Click to Download and Play&lt;/button&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div id="status"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript" src="cordova.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/app.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>document.addEventListener('deviceready', deviceready, false);
  
  var buttomDom;
  var statusDom;
  var fileSystem;
  
  function deviceready() {
      console.log('dv ready');
  
      //step one is to request a file system  
      window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, 
          function(fs) {
              fileSystem = fs;
  
              buttonDom = document.querySelector('#startDl');
              buttonDom.addEventListener('touchend', startDl, false);
              buttonDom.removeAttribute("disabled");
  
              statusDom = document.querySelector('#status');
          }, function(e) {
              alert('failed to get fs');
              alert(JSON.stringify(e));
          });
  }
  
  function startDl() {
      buttonDom.setAttribute("disabled","disabled");
  
      var ft = new FileTransfer();
      var uri = encodeURI("http://archive.org/download/Kansas_Joe_Memphis_Minnie-When_Levee_Breaks/Kansas_Joe_and_Memphis_Minnie-When_the_Levee_Breaks.mp3");
  
      var downloadPath = fileSystem.root.fullPath + "/download.mp3";
  
      ft.onprogress = function(progressEvent) {
          if (progressEvent.lengthComputable) {
              var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
              statusDom.innerHTML = perc + "% loaded...";
          } else {
              if(statusDom.innerHTML == "") {
                  statusDom.innerHTML = "Loading";
              } else {
                  statusDom.innerHTML += ".";
              }
          }
      };
  
      ft.download(uri, downloadPath, 
      function(entry) {
          statusDom.innerHTML = "";
          var media = new Media(entry.fullPath, null, function(e) { alert(JSON.stringify(e));});
          media.play();
  
      }, 
      function(error) {
          alert('Crap something went wrong...');  
      });
  
  
  }
  </code></pre>