Working with prepopulated sqlite database in phonegap android

后端 未结 2 440
太阳男子
太阳男子 2020-12-07 06:30

I have an sqlite database test_db.db i have kept in the www folder i am using cordova cli to build android app on my local machine.

when i am trying to open the data

相关标签:
2条回答
  • 2020-12-07 06:42

    To open prepopulated db in cordova project, you need to do 3 steps:

    1. Copy .db file into main www directory

      Install this plugin and use copy method(this will copy the .db file to the specified directory for your os/device)

      Use this plugin to open the .db file

    Thats it... :)

    0 讨论(0)
  • 2020-12-07 06:46

    Hello I got the solution for this question.

    while opening the database in the folling code

    var db = window.sqlitePlugin.openDatabase({ name : "test_db.db" });

    Add a parameter like this

    var db = window.sqlitePlugin.openDatabase({ name : "test_db.db", createFromLocation : 1 });

    Then it will take the database which you have kept in the www folder.

    0 讨论(0)
提交回复
热议问题