title: Caching in A BlackBerry application
body: <p>I've implemented a set of methods to cache data, but it does not seem to work in BlackBerry (works OK in Android and iOS).</p>
  
  <p>I am using Cordova FileSystem API and WebWorks for debugging.<br>
  Does anyone have any idea how to solve this problem? </p>
  
  <p><strong>Saving Cache:</strong></p>
  
  <pre><code>saveCache: function(fileName, data, writeEnd, onFail){// Takes Two parameters ;the fileName that will be generated and its content (JSON format : Adapter Result)
              if (typeof LocalFileSystem != 'undefined') {
  
                  window.requestFileSystem(LocalFileSystem.TEMPORARY, 1024 * 1024, gotFS, fail);//Invoking Cordova's FileSystem
  
                  function gotFS(fileSystem) {
                      fileSystem.root.getFile(fileName, {create: true}, gotFileEntry, fail);//Creating Cache File named fileName
                      function gotFileEntry(fileEntry) {
                          fileEntry.createWriter(gotFileWriter, fail);//Calling the fileWriter , if Success it writes the data into the file, If failure calls fail method to display the error
                      }
                      function gotFileWriter(writer) {
                          writer.onwriteend = function(evt) {
                              console.log("Write Ended");
                              writeEnd();
                          };
  
  
                             writer.write(Base64.encode(data));// Writing data  
  
  
                      }
                  }
  </code></pre>
  
  <p><strong>Loading From Cache</strong> </p>
  
  <pre><code>loadCache: function(filename, loadEnd, onFail){
              if (typeof LocalFileSystem != 'undefined') {
  
  window.requestFileSystem(LocalFileSystem.TEMPORARY, 1024 * 1024, gotFS, fail);
  
                  function gotFS(fileSystem) {
                      fileSystem.root.getFile(filename, { create: false }, gotFileEntry, fail);
                      function gotFileEntry(fileEntry) {
                          fileEntry.file(gotFile, fail);
                      }
                      function gotFile(file){
                          readAsText(file);
                      }
                      function readAsText(file) {
                          var reader = new FileReader();
  
                          reader.onloadend = function(evt) {
                              console.log("Read as text");
                              //console.log(Base64.decode(evt.target.result));   
                              alert(evt.target.result);
                              loadEnd(Base64.decode(evt.target.result));
                          };
                          reader.readAsText(file);
  
                      }
                  }
                  function fail(evt) {
                      console.log(evt.target.error.code);
                      onFail();
                  }
              }else{
                  onFail();
              }
          },
  </code></pre>