我使用 PhoneGap 完成了移动 (Android) 应用程序的开发。我使用 PhoneGap builder 发布了版本 apk 以将其安装在我的手机上。问题是我的应用程序脱机,因为我使用本地数据库,我如何在手机上的应用程序中安装这个数据库。
Eclipse 正在使用 DDMS 文件资源管理器,但在电话上是如何发生的?
First, you dont need to install a database, you need to call openDatabase to create basic database, after that you need to create table and put in the values to them..
You can refer to the API doc of Phone gap here...
Sample code :
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);