问题
Am new in developing android app in Dreamweaver CC with Phone-gap. I designed simple form in that having 4 fields I need to store this fields in sqlite database? In eclipse import sqlite database and open database connection and then create table and store data. This is working fine, I need to do same here in Dreamweaver CC?
import android.database.sqlite.SQLiteDatabase;
SQLiteDatabase db;
db = this.openOrCreateDatabase("QAOD", MODE_PRIVATE, null);
db.execSQL("INSERT INTO TableName(Id) VALUES(18)");
This format code is working fine in eclipse android but I need use this code and store data in sqlite in Dreamweaver CC with Phone-gap. Help me or suggest me to store data.
回答1:
You mentioned you are using Phonegap
. These are the steps to create and add records to sqlite database
in Android
First: Add Plugin
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin
Second: Open Database
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase({name: "my.db"});
}
Third: Use it (Create, Update or Delete)
db.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS test_table');
tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');
// demonstrate PRAGMA:
db.executeSql("pragma table_info (test_table);", [], function(res) {
console.log("PRAGMA res: " + JSON.stringify(res));
});
You can read more here...
来源:https://stackoverflow.com/questions/27876632/how-to-store-data-in-sqlite-database-using-jquery-mobile-dreamviewer-cc-with-pho