function populateDB(tx) {
console.log("4. populateDB(tx) begins");
var d = new Date();
var new_id = d.getTime(); // set the current time as the id
console.log("id = " + new_id);
var formdata1Get = localStorage.getItem('formdata1Set'); // get data from localStorage
var formdata2Get = localStorage.getItem('formdata2Set');
var formdata3Get = localStorage.getItem('formdata3Set');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id TEXT NOT NULL, data1 TEXT NULL, data2 TEXT NULL, data3 TEXT NULL)');
var query1 = "INSERT INTO DEMO (id, data1, data2, data3) VALUES ";
var query2 = "(\\"" + new_id + "\\", \\"" + formdata1Get + "\\", \\"" + formdata2Get + "\\", \\"" + formdata3Get + "\\")";
var query = query1 + query2;
tx.executeSql('INSERT INTO DEMO (id, data1, data2, data3) VALUES (\\"' + new_id + '\\"' + ', \\"' + formdata1Get + '\\", \\"' + formdata2Get + '\\", \\"' + formdata3Get + '\\")');
queryDB(tx);
}
Unfortunately, the data is not retained in a device when the app is exited. In a device, it behaves just like sessionStorage.
Also, as it stands, the data is repeated with each submission with the “innerHTML+=” scripting – it repeats all the earlier submissions as well as the latest one.