我已经使用 window.requestFileSystem 为我的应用程序声明了一个“文件系统”。难道我不应该有办法删除这个目录中的文件吗?我搜索了 cordova 文件删除扩展,但没有看到任何扩展,所以我希望有一些基于 html5/javascript 的东西。
最佳答案
您可以使用如下所示的内容:
var path = "file:///storage/emulated/0";
var filename = "myfile.txt";
window.resolveLocalFileSystemURL(path, function(dir) {
dir.getFile(filename, {create:false}, function(fileEntry) {
fileEntry.remove(function(){
// The file has been removed successfully
},function(error){
// Error deleting the file
},function(){
// The file doesn't exist
});
});
});
来源:http://ourcodeworld.com/articles/read/28/how-to-delete-file-with-cordova
关于javascript - 有没有办法使用基于 cordova 的移动应用程序删除设备上的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45578914/