Forums

OverviewV-Play 1 Supportstorage – not persistent › Reply To: storage – not persistent

OverviewV-Play 1 Supportstorage – not persistent › Reply To: storage – not persistent
#6239

Christian
V-Play Team

Hi Michael,

the problem here is not the storage persistence, but the readFile function. As I do not have your file contents I cannot reproduce the problem – but you can test it without the file reading, if ou just call something like the following in onCompleted:

myLocalStorage.setValue("ZEBRA", "abc")

If you did that, you will also see that your else-branch should be one colon behind, like in this modified version:

var isFirstStartApplication = myLocalStorage.getValue("ZEBRA")

      if (isFirstStartApplication == undefined) {

          // if undefined is returned, load up database

          var storageData = fileUtils.readFile("files/dictionary.txt")

          if (storageData) {

              loadStatus = "loaded OK!"

              var arr = storageData.split(",");
              console.debug("words read = " + arr.length)
              loadStatus = "words read = " + arr.length

              // parse cvs file to populate storage

              var obj = {};
              for (var i = 0; i < arr.length - 1; i += 1) {
                  myLocalStorage.setValue(arr[i + 1], true)
              }

          } /* DONT put the else branch here, but in the following position
          else {
              loadStatus = "loaded failure!"
              console.debug("loaded file FAILED")
          }*/

        } else {
          loadStatus = "loaded failure!"
          console.debug("loaded file FAILED")
        }
        
      }// end of onCompleted

Cheers, Chris

 

 

 

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support