How to move / copy a file from one folder to another folder in Android using a phone screen saver?

In my application, when I click the button, I can upload the file from the url to SDCARD for android, whose path is similar to "mnt / sdcard / files / data.pdf" , and now I want to move / copy this file to another destination folder using the phone screensavers. Can someone help me how to do this in a telephone bundle?

I have a pdf file in the path "mnt / sdcard / files / data.pdf" and I want to transfer this PDF file to the new path "mnt / sdcard / download / data.pdf" , someone please help me.

+5
source share
1 answer

Assuming that you are actually using Cordoba, check out FileEntry , which has methods called moveToand copyTo.

Keep in mind that the file systems API is a callback addon.

One quick example from non-documented documentation:

var fail = function(err) { console.log(err) }
window.resolveLocalFileSystemURI("file:///example.txt", function(file) {
   window.resolveLocalFileSystemURI("file:///directory-to-move-to", function(destination) {
             file.moveTo(destination,"example.txt");
   },fail)
},fail);

I skipped error handling functions for clarity, suppose it works without it.

+6
source

All Articles