Local Storage, our approach

Last week we sorted out the UI/UX (http://www.clefsoftware.com/blog/bioiq-ux-ultrabook).  This week we worked on settling on an approach for local storage.


At the outset, our preference was to use SQLite.  These features  make it a good choice for our context. We have used it before, are familiar with it and we like it. We weren’t able to get it to work in our first attempt.  We dug around and asked some friends.  The official word is that SQLite added support for Windows 8 (http://www.sqlite.org/news.html) and relevant JavaScript library is also available.  To take advantage of these, we spent some more time trying to get it going.  That was not to be since we are stuck with a “0x800401f9 - JavaScript runtime error: Error in the DLL


In case someone wants to give it a shot , here are some detailed notes.  At a high level, its straight forward–

(1) Find and install SQLite3 plug-in from Visual-Studio store

(2) Download JS library and add to the project

        Copy SQLite3 (downloaded as part of JS library) to VisualStudio project work-space

        Added SQLite3 reference to the project ( right click on the Solution > Add > Add reference and add)

(3) Enable Windows VC++ run-time package and SQLite3 for WRT thru ‘Add reference’ option.

(4) Add SQLite3.js library to the project. 


We would have liked to dig in a bit and solve this (we will tell you our motivation for this in a future post).  Now, we do want to keep the show on the road  so we decided to come up with alternate options.


This MSDN article, summarizing different options available for app-data storage is a good starting point.


We considered IndexedDB and played around a bit with it. IndexedDB has an ‘experimental technology’ tag on it and given that Win 8, itself is new, we decided to go with go with the recommended Local Storage option.  Let us know if you have SQLite working and/or if you would have chosen IndexedDB instead of the local store approach.  Meanwhile, below are some code snippets from our current implementation around the local storage.


The code below shows the data-initialization for BioIQ Game. Making use of “Windows.Storage.ApplicationData”   (class providing access to application’s data-store)  and  ApplicationData.LocalSettings ( Gets the application settings container in the local app data store).


/* ******************

Windows.Storage.ApplicationData & ApplicationData.LocalSettings object reference created in default.js

********** */

var applicationData = Windows.Storage.ApplicationData.current;

var localSettings = applicationData.localSettings;


/* *******************************

Game-master data initiated  in index.htm. ( work in-progress  code)

********************************* */

function createGameLevelData(filename, gamename, gaame_package, purchased, purchaseddate, label_count, start_time, end_time, attempts, labels_answered, all_labels_ok)


    var composite = new Windows.Storage.ApplicationDataCompositeValue();

    if  (!localSettings.values[gamename]) {

       composite['filename'] = filename;

        composite['gamename'] = gamename;

        composite['package'] = game_package;

        composite['purchased'] = purchased;

        localSettings.values[gamename] = composite;


   composite = localSettings.values[gamename];



// *************** end of game-data initialization function


The code below showing the selection of default game to be played (using Applicaton local data).

/* ******************

Function to determine which game to play next. Makes use of user-history (game-play), game-purchase status details.

*********************** */

function loadDefaultGame() {

    var currentgame;

    var gamedata = new Windows.Storage.ApplicationDataCompositeValue();

    //On game-launch, check the current game to be played from Local-app-data-storage

    if (!localSettings.values["CurrentGameDetails"])


        gamedata["gamename"] = "plantcell";

        localSettings.values["CurrentGameDetails"] = gamedata;


     // Get the nextgame to be played based on previously played game

    gameData = localSettings.values["CurrentGameDetails"];


    currentGame = gameData["gamename"];

    var gamePurchasedState = localSettings.values[currentGame];


    if (gamePurchasedState["purchased"] == 0)




    else {

        //load the corresponding game

        location.href = currentGame + ".html";




In summary - to avoid being blocked, we have proceeded with the MS recommended local storage approach.  It will work fine for our current release.  Sometime in the future we do expect to revisit this choice.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Enter the characters shown in the image (to confirm you are not a machine)