This feature enables your mobile application to access SQLite databases. It enables you to store data in a structured database that can be queried using a standard SQL syntax.
This feature is supported in the following platforms:
Installation
Execute the following command in your Cordova project directory:
cordova plugin add cordova-sqlite-storage
Usage
// This function opens the SQLite database and executes a SQL query.
this.fm.registerHandler("cbxclick", "SQLITE",
function (fm, event, fieldName, value)
{
var params =
{
name: 'demo.db',
location: 'default'
};
canvas.dbReference = canvas.env.storage.sqlite.openDatabase(params);
canvas.env.storage.sqlite.executeSql
( canvas.dbReference,
'CREATE TABLE CANVAS (USER TEXT)',
[],
successCB,
errorCB
);
});
// This function is called when SQL query successfully executed.
function successCB(success)
{
showAlert("success");
}
// This function is called when SQL query is not successfully executed.
function errorCB(error)
{
showAlert("error");
}