PhoneGap文件删除不工作 [英] PhoneGap File Remove not working
问题描述
我正在建立一个基本的应用程序,具有PhoneGap相当大,因为我试图确定它可以/不能做。我已经到了舞台,我想要删除已经下载的应用程序,但它不会工作的文件。我使用的大部分代码来自 http:// docs .phonegap.com / en / 2.4.0 / cordova_file_file.md.html#FileEntry ;
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.com/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);
}
我使用HTML调用它;
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.
顺便说一句,我编写的iOS,并使用JavaScript,HTML和Xcode中的PhoneGap / Cordova。
By the way I'm coding for iOS and using JavaScript, HTML and PhoneGap/Cordova in Xcode.
我是iPhone开发的新手,所以任何帮助将非常感谢很多:)
I'm fairly new to iPhone development so any help would be great thanks a lot :)
推荐答案
您的代码略有偏离。尝试:
Your 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);
}
这篇关于PhoneGap文件删除不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!