PhoneGap (Android) Delete Directory
android, cordova
Solution
I have done it with this approach:
function ClearDirectory() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
function fail(evt) {
alert("FILE SYSTEM FAILURE" + evt.target.error.code);
}
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getDirectory(
"yours/dir/ect/ory",
{create : true, exclusive : false},
function(entry) {
entry.removeRecursively(function() {
console.log("Remove Recursively Succeeded");
}, fail);
}, fail);
}
}
Problem
I'm trying to delete a directory and it's contents with `PhoneGap on Android` using: ``` deleteDirectory = function deleteDirectory(uri) { uri = uri.substring(0, uri.lastIndexOf('/')); return $.Deferred(function (def) { fileSystem.root.getDirectory(uri, { create: false }, function (directory) { directory.removeRecursively(); def.resolve(); }, function (error) { resolveError("Error deleting directory: ", error, def); }); }).promise(); } ``` with the following error: `File No Modification Allowed Error` I've confirmed this permission is set: ``` <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ``` Where else should I be looking?