PhoneGap的(安卓)删除目录
问题描述:
我想删除一个目录和它的使用与 PhoneGap的内容在Android上:
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();
}
,出现以下错误:文件无修改允许误差
我已经证实了这一权限设置为:
I've confirmed this permission is set:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在别的地方,我应该找?
Where else should I be looking?
答
我已经使用这种方法做到了:
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);
}
}