Copying a file using Cordova

前端 未结 4 1461
旧时难觅i
旧时难觅i 2021-01-19 03:21

I\'ve been trying to copy file named versions.txt from applicationDirectory to externalApplicationStorageDirectory using cordova but code fails.

here is the code

4条回答
  •  梦毁少年i
    2021-01-19 03:41

    now it works, target directory should be resolved.

    here is the solution

    window.resolveLocalFileSystemURL(cordova.file.externalApplicationStorageDirectory,
                          function onSuccess(dirEntry)
                          {
                              //alert(JSON.stringify(dirEntry));
    
                              fileEntry.copyTo(dirEntry, 'versions.txt',
                                  function()
                                  {
                                      alert('copying was successful')
                                  },
                                  function()
                                  {
                                      alert('unsuccessful copying')
                                  });
                          }, null);
    

提交回复
热议问题