PhoneGap File Remove not working
cordova, html, javascript, xcode
Solution
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);
}
Problem
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); } ``` 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 :)