title: How do i save a very long string?
body: <p>I am creating a mobile app and i have encounted a problem on blackberry phones (most of my users are using blackberry). I am using phonegap api. </p>
  
  <p>The problem is that i am downloading a string which i am saving in localstorage on the phone's browser and when the string gets over x million chars localstorage is no longer able to store the string. I need at least 10 times more space than localstorage provides me with.</p>
  
  <p>I have tried saving the string as a text file instead and followed the docs provided by phonegap but could not manage to read or write to file so i gave up (i think this is the only way for me to do this). Also have looked into compressing the string but like i said before i need over 10 times the space and i dont see how a 10 char string can be transformed into a 1 char string.</p>
  
  <p>Code for file reader and writer (problem is it never finds or creates the file, getfile() fails for reading or writing and returns error code 1 - file_not_found):</p>
  
  <pre><code>function OnLoadSignInCheck(){
  
      alert("1");
       document.addEventListener("deviceready", onDeviceReady, false);
  
  }
  
  function onDeviceReady() {
  alert("2");
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
  }
  
  function gotFS(fileSystem) {
  alert("3");
      fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry, fail);
  }
  
  function gotFileEntry(fileEntry) {
  alert("4");
      fileEntry.createWriter(gotFileWriter, fail);
  }
  
  function gotFileWriter(writer) {
  alert("5");
      writer.onwriteend = function(evt) {
          alert("contents of file now 'some sample text'");
          writer.truncate(11);  
          writer.onwriteend = function(evt) {
              alert("contents of file now 'some sample'");
              writer.seek(4);
              writer.write(" different text");
              writer.onwriteend = function(evt){
                  alert("contents of file now 'some different text'");
              }
          };
      };
      writer.write("some sample text");
      reader();
  }
  
  function fail(error) {
      alert(error.code);
  }
  
  function reader() {
  alert("1");
  window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFSr, fail);
  }
  
  function gotFSr(fileSystem) {
      alert("2");
      fileSystem.root.getFile("readme.txt", null, gotFileEntryr, fails);
  }
  
  function gotFileEntryr(fileEntry) {
      alert("3");
      fileEntry.file(gotFiler, fails);
  }
  
  function gotFiler(file){
      alert("4");
      readDataUrl(file);
      readAsText(file);
  }
  
  function readDataUrl(file) {
      var reader = new FileReader();
      reader.onloadend = function(evt) {
          alert("Read as data URL");
          alert(evt.target.result);
      };
      reader.readAsDataURL(file);
  }
  
  function readAsText(file) {
      var reader = new FileReader();
      reader.onloadend = function(evt) {
          alert("Read as text");
          alert(evt.target.result);
      };
      reader.readAsText(file);
  }
  
  function fails(evt) {
      alert(evt.target.error.code);
  }
  </code></pre>