You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ophir LOJKINE edited this page Jun 13, 2014
·
7 revisions
If your database is in the array dbFile and you open it with db = SQL.open(dbFile) the dbFile array will contain the modified database. It is possible to save the dbFile by stringifying it then sending it back to the originating server or saving it in local storage with localStorage['localSQLiteDB'] = strdb;.
Save a database to a string
Here, we save the db to localStorage:
functiontoBinString(arr){varuarr=newUint8Array(arr);varstrings=[],chunksize=0xffff;// There is a maximum stack size. We cannot call String.fromCharCode with as many arguments as we wantfor(vari=0;i*chunksize<uarr.length;i++){strings.push(String.fromCharCode.apply(null,uarr.subarray(i*chunksize,(i+1)*chunksize)));}returnstrings.join('');}window.localStorage.setItem("mydata",toBinString(db.export()));
Load from a string
Use the following to load a database from localStorage: