admin管理员组文章数量:1314239
I am building up a basic app which features PhoneGap pretty heavily as i am trying to determine what it can/can't do. i have gotten to the stage where i am looking to remove a file that has been downloaded on the app, but it won't work. most of the code i've used is from .4.0/cordova_file_file.md.html#FileEntry;
function removefile(){
fileSystem.root.getFile("readme.txt", {create: false, exclusive: false}, gotRemoveFileEntry, fail);
}
function gotRemoveFileEntry(fileEntry){
console.log(fileEntry);
fileEntry.file(gotFile, fail);
entry.remove(success, fail);
}
function success(entry) {
console.log("Removal succeeded");
}
function fail(error) {
console.log("Error removing file: " + error.code);
}
and i have called it using the HTML;
<button onclick="removefile();">remove file</button>
is there something wrong with the code? i can't see it.
By the way I'm coding for iOS and using JavaScript, HTML and PhoneGap/Cordova in Xcode.
I'm fairly new to iPhone development so any help would be great thanks a lot :)
I am building up a basic app which features PhoneGap pretty heavily as i am trying to determine what it can/can't do. i have gotten to the stage where i am looking to remove a file that has been downloaded on the app, but it won't work. most of the code i've used is from http://docs.phonegap./en/2.4.0/cordova_file_file.md.html#FileEntry;
function removefile(){
fileSystem.root.getFile("readme.txt", {create: false, exclusive: false}, gotRemoveFileEntry, fail);
}
function gotRemoveFileEntry(fileEntry){
console.log(fileEntry);
fileEntry.file(gotFile, fail);
entry.remove(success, fail);
}
function success(entry) {
console.log("Removal succeeded");
}
function fail(error) {
console.log("Error removing file: " + error.code);
}
and i have called it using the HTML;
<button onclick="removefile();">remove file</button>
is there something wrong with the code? i can't see it.
By the way I'm coding for iOS and using JavaScript, HTML and PhoneGap/Cordova in Xcode.
I'm fairly new to iPhone development so any help would be great thanks a lot :)
Share Improve this question edited Feb 19, 2013 at 17:01 Emil 7,25618 gold badges80 silver badges135 bronze badges asked Feb 19, 2013 at 16:52 Megan SimeMegan Sime 1,2672 gold badges16 silver badges25 bronze badges2 Answers
Reset to default 5Your code is slightly off. Try:
function removefile(){
fileSystem.root.getFile("readme.txt", {create: false, exclusive: false}, gotRemoveFileEntry, fail);
}
function gotRemoveFileEntry(fileEntry){
console.log(fileEntry);
fileEntry.remove(success, fail);
}
function success(entry) {
console.log("Removal succeeded");
}
function fail(error) {
console.log("Error removing file: " + error.code);
}
Old entry. The API may have changed, but I was able to do it like this:
function success(entry) {
console.log("Removal succeeded");
}
function fail(error) {
console.log("Error removing file: " + error.code);
}
resolveLocalFileSystemURL(cordova.file.dataDirectory + 'assets/icons/test.png', function(entry) {
console.log(entry);
entry.remove(success, fail);
})
本文标签: javascriptPhoneGap File Remove not workingStack Overflow
版权声明:本文标题:javascript - PhoneGap File Remove not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741926336a2405310.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论