2012-06-22 84 views
2

我想在PhoneGap的(IOS)删除图像,所以我呼吁:entry.remove(成功,失败)调用成功,但不删除图像

window.resolveLocalFileSystemURI(imageURI, ok, no); 

这个调用OK功能

function ok(entry) { 
      alert("Deleting: " + entry.name); 
      entry.remove(); 
     } 

所以一切都按计划进行,但我的图像仍然显示在我的图书馆。我究竟做错了什么?

完整的源:

window.resolveLocalFileSystemURI(imageURI, ok, no); 
     function ok(entry) { 
      alert("Delete file entry: " + entry.name); 
      entry.remove(pictureRemoved, notRemoved); 
     } 
     function pictureRemoved(){ 
      alert('removed'); 
     } 
     function notRemoved(){ 
      alert('not Removed'); 
     } 
     function no(error) { alert 
     ("resolveFileSystemURI failed: " + error.code); } 

回答

0

尝试用下面的代码:

//Delete file 
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, 
    function(fileSys) { 

     fileSys.root.getFile(imageURI, {create: false}, 
      function(file) { 
       file.remove(pictureRemoved, notRemoved);             
      }, no); 
    }, no); 

它为我工作。

+0

举个完整的例子 – Patel

0

添加文件插件。它会工作。