I\'m new to this, and I am trying to build an app to be deployed with PhoneGap, to both Android and iOS. I am wondering how to link to a database which will store timetable dat
Careful because maxSize of database in Android Gingerbread 2.3.3 emulator must be 65535.
With this OS 200000 maxSize it could give an error.
200000 maxSize works for newer OS.
PhoneGap has a storage api that you should use instead of using HTML5 local storage directly. On both Android and iOS, it will use the native implementation.
see http://docs.phonegap.com/en/2.7.0/cordova_storage_storage.md.html#Storage
Please refer below link for simple operation with Sq-lite.and also you can get basic idea of Storage API from above link.
Simple operation with Sq-lite : http://www.raymondcamden.com/index.cfm/2011/10/20/Example-of-PhoneGaps-Database-Support
Edited on 8th MAY 2013 and fixed 19th January 2016
Basic operation with DB :
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(populateDB, errorCB, successCB);
}
// Populate the database
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")');
}
// Transaction error callback
function errorCB(err) {
alert("Error processing SQL: " + err);
}
// Transaction success callback
function successCB() {
alert("success!");
}
</script>
refrence
You can check Data base in File explorer
In ADT bundle Window>>show view>> File Explorer