How to store data in sqlite database using jQuery-mobile dreamviewer cc with telephone connection in android?

New to Android app development in Dreamweaver CC with Phone-gap. I developed a simple form in that having 4 fields, do I need to store these fields in a sqlite database? In eclipse, import the sqlite database and open a database connection, then create a table and save the data. This works great, do I need to do the 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 code format works fine in eclipse android, but I need to use this code and store the data in sqlite in Dreamweaver CC with Phone-gap. Help me or suggest me to store data.

+6
source share
1 answer

You mentioned that you use 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 the 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 here ...

+4
source

Source: https://habr.com/ru/post/980801/


All Articles