0
votes

I have followed all of the examples for how to do this and I have not been able to get cordova-sqlite-ext to work. This has been a very long week... I have a simple SQLite database that has been tested to work correctly in an SQLite viewer. I have stuck this in www/ (and also like 3 other locations to pray I can get this to work). I have had 0 luck. I always get the result of "table data does not exist" when it definitely does.

Testing Software: Android 5.0.1

cordova plugin list:
cordova-plugin-dbcopy 2.1.2 "sqlDB"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.0.1 "cordova-plugin-ionic-webview"
cordova-plugin-is-debug 1.0.0 "IsDebug"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-ext 3.0.1 "Cordova sqlite storage plugin with extra features"
cordova-sqlite-storage 3.4.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
es6-promise-plugin 4.2.2 "Promise"
uk.co.workingedge.cordova.plugin.sqliteporter 1.1.1 "sqlite porter"
import { Platform } from '@ionic/angular';
import { Injectable } from '@angular/core';
//import { SQLitePorter } from '@ionic-native/sqlite-porter/ngx';
import { HttpClient } from '@angular/common/http';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';
import { BehaviorSubject, Observable } from 'rxjs';

export class DatabaseService {

private database: SQLiteObject;
private dbReady: BehaviorSubject = new BehaviorSubject(false);

constructor(private sqlite: SQLite,
private plt: Platform,
) {
this.startDatabase();
}

startDatabase(){

let options = {
  name: "asv.sqlite",
  location: 'default',
  createFromLocation: 1 
}

this.plt.ready().then(() => {
  this.sqlite.create(options).then((db: SQLiteObject) => {
    //this.database = db;
    db.executeSql('select distinct book_name from data', [])
    .then((data) => {
      console.log("Grabbed Books")
      console.log(data)
    });
    //this.seedDatabase(bible_version);
  })
  .catch(e => {
    console.error(e)
  });  
});
//});
}

Note: I have been able to get this to work by converting the sqlite database into a SQL database and using porter to convert it over. But this is obviously a funky way to do things as I dont want to build a database when i can prebuild it.

Also. I have tried changing the name of the database to something else, and building tables and it works fine. I was able to gather some fake data i threw in.

On a separate note. i'm trying to locate this file in my app on my android, where does default place it if its not in www/?

UPDATE: I found that a database file is indeed being create in the data/data//database folder. How can i get it to use my database without using dbcopy! dbcopy requires android 8, this cuts off 20% of android users (plus my testing device hehe)

1

1 Answers

0
votes

I finally figured it out. After a week, i answer it on the day after I ask the question lol. So, for future people, check your packages. I had the non ext version of the sqlite-storage also installed and my app was using that package instead. " cordova-sqlite-storage 3.4.0 "Cordova sqlite storage plugin - cordova-sqlite-storage" I uninstalled and remove from cordova (cordova plugin rm cordova-sqlite-storage) and it works. UGH

Old Plugins:
cordova plugin list:
cordova-plugin-dbcopy 2.1.2 "sqlDB"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.0.1 "cordova-plugin-ionic-webview"
cordova-plugin-is-debug 1.0.0 "IsDebug"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-ext 3.0.1 "Cordova sqlite storage plugin with extra features"
cordova-sqlite-storage 3.4.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
es6-promise-plugin 4.2.2 "Promise"
uk.co.workingedge.cordova.plugin.sqliteporter 1.1.1 "sqlite porter"
New Plugins:
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.0.1 "cordova-plugin-ionic-webview"
cordova-plugin-is-debug 1.0.0 "IsDebug"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-ext 3.0.1 "Cordova sqlite storage plugin with extra features"
es6-promise-plugin 4.2.2 "Promise"
uk.co.workingedge.cordova.plugin.sqliteporter 1.1.1 "sqlite porter"