PhoneGap的(安卓)删除目录 [英] PhoneGap (Android) Delete Directory
本文介绍了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);
}
}
这篇关于PhoneGap的(安卓)删除目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文