In my application on button click i am able to download a file from url into my SDCARD of android whose path is something like "mnt/sdcard/files/data.pdf" and now i want to move/copy this file to some other destination folder using phonegap. Can anyone please help me how to do this in phonegap?
I have a pdf file in path "mnt/sdcard/files/data.pdf" and i want to move that pdf file to new path "mnt/sdcard/download/data.pdf" anyone please help me.
You can move a file or folder from one folder to another by dragging it from its current location and dropping it into the destination folder, just as you would with a file on your desktop. Folder Tree: Right-click the file or folder you want, and from the menu that displays click Move or Copy.
Okay, so we have the AOSP files app open. Copying or moving data out of the "Android/data" folder is, thankfully, pretty simple. Simply navigate to the folder as usual, long-press on the content you want to select, then go to the three-dot menu in the upper-right and choose either "Copy to..." or "Move to...".
Assuming you are actually using Cordova, check FileEntry, which has methods named moveTo
and copyTo
.
Be aware that the file systems API are a callback hell.
One quick example from the docs cooked overlooking the docs:
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 the error handling functions for clearness, suppose it works without it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With