Cordova 如何使用phonegap读取目录中的保存文本文件

Cordova 如何使用phonegap读取目录中的保存文本文件,cordova,Cordova,我正在目录中保存一个文件,其中包含一些数据,但现在需要在phone gap中读取该文件。我尝试了此操作,但无法读取该文件。 这是我的保存文件和读取文件代码?我没有读取任何数据?我也学习phonegap文档,但不会阅读 function saveDataOnTextFile(){ try { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem)

我正在目录中保存一个文件,其中包含一些数据,但现在需要在phone gap中读取该文件。我尝试了此操作,但无法读取该文件。 这是我的保存文件和读取文件代码?我没有读取任何数据?我也学习phonegap文档,但不会阅读

function saveDataOnTextFile(){
 try {
           window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
               function(fileSystem) {
                   fileSystem.root.getDirectory(CASENAME, { create: true, exclusive: false }, function(directoryEntry) {
                       console.log("log folder is created");
                       directoryEntry.getFile(DOCUMENT_NAME+".rtf", { create: true, exclusive: false }, function(fileEntry) {
                           fileEntry.createWriter(function(writer) {
                               writer.seek(writer.length);

                               writer.write($('#realTimeContents').text());
                           }, fail);
                       }, fail);
                   }, fail);
               },
               fail);
       }
       catch(e) {
           fail(e+"fail");
       }

}

function readRtfFile(){


 try {
           window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
               function(fileSystem) {
                   fileSystem.root.getDirectory(CASENAME, { create: true, exclusive: false }, function(directoryEntry) {
                       console.log("log folder is created");
                       directoryEntry.getFile(DOCUMENT_NAME+".rtf", { create: true, exclusive: false }, function(fileEntry) {
                           fileEntry.createReader(function(reader) {
                               reader.readEntries(function(entries){
                                var i;
                               for (i=0; i<entries.length; i++) {
                                console.log(entries[i].name);
                                }

                               },fail);


                           }, fail);
                       }, fail);
                   }, fail);
               },
               fail);
       }
       catch(e) {
           fail(e+"fail");
       }




}
函数saveDataOnTextFile(){ 试一试{ requestFileSystem(LocalFileSystem.PERSISTENT,0, 功能(文件系统){ getDirectory(CASENAME,{create:true,exclusive:false},函数(directoryEntry){ log(“创建日志文件夹”); getFile(DOCUMENT_NAME+“.rtf”,{create:true,exclusive:false},函数(fileEntry){ createWriter(函数(writer){ writer.seek(writer.length); writer.write($('realTimeContents').text(); },失败); },失败); },失败); }, 失败); } 捕获(e){ 不合格(e+“不合格”); } } 函数readRtfFile(){ 试一试{ requestFileSystem(LocalFileSystem.PERSISTENT,0, 功能(文件系统){ getDirectory(CASENAME,{create:true,exclusive:false},函数(directoryEntry){ log(“创建日志文件夹”); getFile(DOCUMENT_NAME+“.rtf”,{create:true,exclusive:false},函数(fileEntry){ createReader(函数(读取器){ reader.readEntries(函数(条目){ var i; 对于(i=0;i