I tried to use an HTML in android to create a table in SQLite, but it is not working.
Sample HTML:
<!doctype html>
<html>
<head>
<title>Contact Example</title>
<script
type="text/javascript"
charset="utf-8"
src="phonegap-1.0.0.js"
></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
//document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
var db = openDatabase("Database", "1.0", "PhoneGap 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(tx, err) {
alert("Error processing SQL: " + err);
}
// Transaction success callback
//
function successCB() {
alert("success!");
}
</script>
</head>
<body onload="onDeviceReady()">
<h1>Example</h1>
<p>Database</p>
</body>
</html>
I am not able to see any database created in android 2.2.