小编Mah*_*iba的帖子

Cordova删除文件

我有一个创建文件的工作应用程序.我正在寻找一种方法,可以在工作几个小时后从cordova应用程序中删除文件.我似乎无法使其发挥作用.

这是创建和删除文件的代码:

function crea(){
    alert(cordova.file.externalDataDirectory);
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) {
        alert("got main dir",dir);
        dir.getFile("log1.txt", {create:true}, function(file) {
            alert("got the file", file);

        });
    });
        }



    function del(){
var relativeFilePath = cordova.file.dataDirectory;
var filename = "log1.txt"; 
alert(relativeFilePath);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
  //  alert(fileSystem.root.fullPath);
    fileSystem.root.getFile(relativeFilePath + filename, {create:false}, function(fileEntry){
        fileEntry.remove(function(file){
            alert("File removed!");
        },function(){
            alert("error deleting the file " + error.code);
            });
        },function(){
            alert("file does not exist");
        });
    },function(evt){
        alert(evt.target.error.code);
});

}
Run Code Online (Sandbox Code Playgroud)

最好的祝福.

cordova

6
推荐指数
1
解决办法
9479
查看次数

Cordova android无法从缓存目录中复制图像

我有一个工作的应用程序拍照,但我想将图片从缓存文件夹复制或移动到另一个文件夹.我不能这样做,它返回错误[对象对象].

问候

function copiePhoto() {
try {
    var fail = function (err) {
        alert(err);
    };
    window.resolveLocalFileSystemURI("file:///storage/emulated/0/Android/data/com.coolappz.capigo/cache/1427968060754.jpg", function (file) {
        window.resolveLocalFileSystemURI("file:///test", function (destination) {
            file.moveTo(destination, "test.jpg");
        }, fail);
    }, fail);
} catch (err) {
    alert("copie : " + err);
}
Run Code Online (Sandbox Code Playgroud)

}

image cordova

4
推荐指数
1
解决办法
1068
查看次数

标签 统计

cordova ×2

image ×1