moveTo copyTo methods

2,596 views
Skip to first unread message

Victor

unread,
Jun 4, 2011, 10:43:08 AM6/4/11
to phonegap
Someone please could give me an working example of FileEntry copyTo
and/or moveTo methods?
What I want to do is: get a downloaded database file and copy or move
it to myproject database location folder.
I've already tried PhoneGap Documentation examples, changed variables,
etc.
I'm using Android and the functions are:


function copyFile(entry) {
//assuming my entry is 'file:///sdcard/cache/file.zip' and trying
copy from a sdcard

//I already tried to remove from parent var 'file://'
//and changed this path to other locations
var parent = 'file:///sdcard/',
parentEntry = new DirectoryEntry({
fullPath:parent
});

entry.copyTo(parentEntry, 'newfile.zip', win, fail)

//I tried this way too
//var fent = new FileEntry({
// fullPath:entry
//});
//fent.copyTo(parentEntry, 'newfile.zip', win, fail)
}

function win(entry) {
alert("Entry: " + entry.fullPath);
}

function fail(error) {
alert("Error code: "+error.code+" "+errNames(error.code));
}

When I try execute the function I don't get any error or success
message.

Simon MacDonald

unread,
Jun 5, 2011, 12:04:20 AM6/5/11
to phon...@googlegroups.com
Get rid of the file:// in your parent variable declaration and you
should be okay. You should be calling window.requestFileSystem() to
get the root anyway.

Simon

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>

--
Simon Mac Donald
http://hi.im/simonmacdonald

pab

unread,
Aug 5, 2011, 6:16:24 AM8/5/11
to phon...@googlegroups.com
Hi Simon,

can i use resolveLocalFileSystemURI() for this moveTo function


function moveFile(entry) {
var parent = window.resolveLocalFileSystemURI("file:///sdcard/newfolder",
onSuccess,
onError);,


parentEntry = new DirectoryEntry({
fullPath:parent
});

entry.moveTo(parentEntry, 'newfile.zip', win, fail)
}


function win(entry) {
alert("Entry: " + entry.fullPath);
}

function fail(error) {
alert("Error code: "+error.code+" "+errNames(error.code));
}

function onSuccess(directryEntry) {
var entry = directoryEntry;
}

thanks
-pab


jamiemac...@googlemail.com

unread,
Aug 24, 2011, 10:51:39 AM8/24/11
to phonegap
What is the entry parameter that is supplied. I cannot seem to get
this moveTo to work at all. I dont see how it knows what file you are
trying to move or where it is located

Simon MacDonald

unread,
Aug 25, 2011, 12:50:21 PM8/25/11
to phon...@googlegroups.com

Ali Nahid

unread,
Jan 10, 2012, 11:57:34 PM1/10/12
to phon...@googlegroups.com
Mate I dont think you know how to work it. You are just copy pasting stuffs from
phonegap example. Please only reply if you have a working code. Do not go on
pasting hypothetical codes just to claim points.

Simon MacDonald

unread,
Jan 11, 2012, 10:01:59 AM1/11/12
to phon...@googlegroups.com
Ali, thank you for your insightful commentary. If you first ever post
is indicative of future messages, I suspect you will raise the level
of engagement on the list.

Reply all
Reply to author
Forward
0 new messages