In my android phonegap application I have written plugin to call native code.In native code I am creating sqlite database,creating the table, and inserting data.Here I am trying to open the same database and fetching the data from javascript file using phonegap storage Api. native android code to open database and create table
enter code here
private void openDatabase(String dbname, String password)
{
File dbfile = this.cordova.getActivity().getDatabasePath("TheTeamScore"+ ".db");
myDB = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
}
private void createTableAndInsert()
{
try {
this.openDatabase(dbname, null);
myDB.execSQL("CREATE TABLE IF NOT EXISTS Contacts(id INTEGER NOT NULL,name TEXT NOT NULL, selectedEmail TEXT, selectedPhone TEXT)");
String sql ="INSERT INTO Contacts (id,name,selectedEmail,selectedPhone) VALUES (1,'Saranga','Saranga@gmail.com', '7620765783')";
myDB.execSQL(sql);
}
catch(Exception e)
{
Log.e("Error", "Error", e);
}
}
Javascript file contains the code to open same database(databasename="TheTeamScore") and select data from created table
enter code here
function open_DB() {
return window.openDatabase("TheTeamScore", "1.0", "TheTeamScore DB", 200000);
}
function query_DB(tx) {
if (dbquery == "select"){
tx.executeSql('SELECT * FROM Contacts', [], select_EmailSuccess, error_CBForSelect);
}
}
but above code is unable to fetch data from Contacts table and showing error no table found Contacts .How to open the same database and use the table using phonegap