cetinDev
cetinDev

Reputation: 319

Unable to open database cordova_not_available

I coding in ionic2 and I using Sqlite but I take this error "Unable to open database cordova_not_available". How can ı solve this problem

Thanx for help.

My error(Unable to open database cordova_not_available)

My Code;

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
import { TabsPage } from '../pages/tabs/tabs';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = TabsPage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {



    platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();


       let db = new SQLite();
       db.create({
                name: "iothook.db",
                location: "default"
            }).then((db1:SQLiteObject) => {
                db1.executeSql("CREATE TABLE IF NOT EXISTS kullanici (id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT , token TEXT , user_id INTEGER)", {}).then((data) => {
                    console.log("TABLE CREATED: ", data);
                }, (error) => {
                    console.error("Unable to execute sql", error);
                })
            }, (error) => {
                console.error("Unable to open database", error);
            });

    });
  }
}

Upvotes: 0

Views: 1770

Answers (1)

HGK
HGK

Reputation: 181

Cordova functionalities are available only on mobile devices. They are not supported in browser.

Upvotes: 5

Related Questions