N/A
<plugin name="Storage" value="org.apache.cordova.Storage" />
No permissions are required.
No permissions are required.
var dbShell = window.openDatabase(database_name, database_version, database_displayname, database_size);
var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
function populateDB(tx) { tx.executeSql('DROP TABLE IF EXISTS DEMO'); tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); } function errorCB(err) { alert("Error processing SQL: "+err.code); } function successCB() { alert("success!"); } var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); db.transaction(populateDB, errorCB, successCB);
function populateDB(tx) { tx.executeSql('DROP TABLE IF EXISTS DEMO'); tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); } function errorCB(err) { alert("Error processing SQL: "+err); } function successCB() { alert("success!"); } var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); db.transaction(populateDB, errorCB, successCB);
function queryDB(tx) { tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); } function querySuccess(tx, results) { console.log("Returned rows = " + results.rows.length); // this will be true since it was a select statement and so rowsAffected was 0 if (!resultSet.rowsAffected) { console.log('No rows affected!'); return false; } // for an insert statement, this property will return the ID of the last inserted row console.log("Last inserted row ID = " + results.insertId); } function errorCB(err) { alert("Error processing SQL: "+err.code); } var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); db.transaction(queryDB, errorCB);
function queryDB(tx) { tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); } function querySuccess(tx, results) { var len = results.rows.length; console.log("DEMO table: " + len + " rows found."); for (var i=0; i<len; i++){ console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " + results.rows.item(i).data); } } function errorCB(err) { alert("Error processing SQL: "+err.code); } var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); db.transaction(queryDB, errorCB);
^유형^
SQLError.UNKNOWN_ERR |
SQLError.DATABASE_ERR |
SQLError.VERSION_ERR |
SQLError.TOO_LARGE_ERR |
SQLError.QUOTA_ERR |
SQLError.SYNTAX_ERR |
SQLError.CONSTRAINT_ERR |
SQLError.TIMEOUT_ERR |
var storage = window.localStorage;