title: Cordova: How to move file to the Download folder?
body: <p><strong>THE SITUATION:</strong></p>
  
  <p>In my mobile app I need to download a file and store in the Download folder.</p>
  
  <p>The download part is working fine.
  The file is properly downloaded from the server and stored in the following folder:</p>
  
  <pre><code>file:///storage/emulated/0/Android/data/org.cordova.MY_APP_NAME.app/my_file.pdf
  </code></pre>
  
  <p>But the location is not really user-friendly. </p>
  
  <p>To access it I have to go to: <em>Internal storage / Android / data / org.cordova.MY_APP_NAME.app /</em> </p>
  
  <p>So I need to move it to the main Download folder.</p>
  
  <p>The file transfer is what I don't manage to do.</p>
  
  <p>I know that there are already several similar questions on SO.</p>
  
  <p>I have tried them all but none really worked for me, I could never see the file in the actual Download folder.</p>
  
  <p><strong>PROJECT INFO:</strong></p>
  
  <p>I am using <a href="http://quasar-framework.org/" rel="nofollow noreferrer">Quasar</a> with <a href="https://vuejs.org/" rel="nofollow noreferrer">Vuejs</a> and <a href="https://cordova.apache.org/" rel="nofollow noreferrer">Cordova</a>.</p>
  
  <p><strong>PLATFORM</strong>:</p>
  
  <p>For the moment I am working with Android. But ideally I am looking for a solution that works for both Android and IOS.</p>
  
  <p><strong>THE CODE:</strong></p>
  
  <p><strong>The download code:</strong></p>
  
  <pre><code>var fileTransfer = new FileTransfer() // eslint-disable-line
  var uri = encodeURI('https://MY_SERVER_PATH')
  
  fileTransfer.download(
    uri,
    cordova.file.externalApplicationStorageDirectory + 'my_file.pdf',
    entry =&gt; {
      console.log('download complete: ' + entry.toURL())
      this.moveFile(entry.toURL())
    },
    error =&gt; {
      console.log('download error source ' + error.source)
      console.log('download error target ' + error.target)
      console.log('download error code' + error.code)
    },
    false,
    {
      headers: {
        'Authorization': 'Basic asdasdasdasdassdasdasd'
      }
    }
  )
  </code></pre>
  
  <p><strong>The File transfer code:</strong></p>
  
  <pre><code>moveFile(fileUri) {
    window.resolveLocalFileSystemURL(
      fileUri,
      fileEntry =&gt; {
        let newFileUri = 'file:///storage/emulated/0/Download'
  
        window.resolveLocalFileSystemURL(
          newFileUri,
          dirEntry =&gt; {
            fileEntry.moveTo(dirEntry, 'new_filename.pdf', this.moveFileSuccess, this.moveFileError)
          },
          this.moveFileError)
      },
      this.moveFileError)
  },
  moveFileSuccess(entry) {
    console.log('file move success')
    console.log(entry)
  },
  moveFileError(error) {
    console.log('file move error')
    console.log(error)
  }
  </code></pre>
  
  <p><strong>THE QUESTION:</strong></p>
  
  <p>How can I move a file to the Download folder?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is the console log of the <code>cordova.file</code> object:</p>
  
  <pre><code>applicationDirectory: "file:///android_asset/"
  applicationStorageDirectory: "file:///data/user/0/org.cordova.MY_APP_NAME.app/"
  cacheDirectory:"file:///data/user/0/org.cordova.MY_APP_NAME.app/cache/"
  dataDirectory: "file:///data/user/0/org.cordova.MY_APP_NAME.app/files/"
  documentsDirectory: null
  externalApplicationStorageDirectory: "file:///storage/emulated/0/Android/data/org.cordova.MY_APP_NAME.app/"
  externalCacheDirectory: "file:///storage/emulated/0/Android/data/org.cordova.MY_APP_NAME.app/cache/"
  externalDataDirectory: "file:///storage/emulated/0/Android/data/org.cordova.MY_APP_NAME.app/files/"
  externalRootDirectory: "file:///storage/emulated/0/"
  sharedDirectory: null
  syncedDataDirectory: null
  tempDirectory: null
  </code></pre>