Skip to content

Persisting a Modified Database

Christopher Weiss edited this page Dec 9, 2013 · 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 after you invoke db.close(). It is possible to save the dbFile by stringifying it with JSON.stringify(dbFile) then sending it back to the originating server or saving it in local storage with localStorage['localSQLiteDB'] = JSON.stringify(dbFile);. If you are starting with a blank database then use the following...

var dbFile = [],
    db = SQL.open(dbFile);
/*
    Create and modify the database.
*/
db.close();
localStorage.localSQLiteDB = JSON.stringify(dbFile);