2015-01-06 105 views

回答

0

是的,应该是可以的。让我们认为该文件位于www/en_US.json,所以当你引用它时,使用的路径应该是en_US.json。另一方面,目的地是cordova.file.documentsDirectory,由File插件指定。所以,现在你知道路径,你需要做的就是用File插件复制文件。这里是完全没有测试的例子,但应该给你的主要想法:

function copyFileToDocuments(fileToBeCopied) { 
    function gotFileEntry(fileEntry) { 
     fileEntry.copyTo(cordova.file.documentsDirectory); 
    } 
    function onFileSystemSuccess(fileSystem) { 
     window.resolveLocalFileSystemURL(this.getDirectory(), function(dirEntry) { 
      dirEntry.getFile(fileToBeCopied, {create: true, exclusive: false}, gotFileEntry.bind(this),  this.errorHandler); 
     }.bind(this)); 
    } 

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess.bind(this), this.errorHandler); 
} 
相关问题