an-rahulpandey / cordova-plugin-dbcopy

Copy SQLite Database from www folder to default app database location
Apache License 2.0
89 stars 48 forks source link

copying multiple databases #46

Closed mmp-schmitt closed 5 years ago

mmp-schmitt commented 7 years ago

Problem with the Android version. It is working fine on iOS.

I am working with two database. One large database used read-only, the other smaller one in read/write mode. So I am starting the copy procedure of two databases. Once they are copied I open them and start working. This does not work as the plugin seems to use a global variable 'dbname' to store the name of the database. I am discovering the following behavior:

  1. Starting copy of database 1 ... waiting
  2. Starting copy of database 2 ... waiting
  3. Database 1 signals successful copying, but when opening it it contains the structure of database 2

As a temporary fix I do this

  1. Starting copy of database 1 ... waiting
  2. Database 1 signals successful, opening database 1
  3. Starting copy of database 2 ... waiting
  4. Database 2 signals successful, opening database 2

This will work.

an-rahulpandey commented 7 years ago

@mmp-schmitt In iOS we can do direct file copy to the database directory thats why it works. However, Android doesn't allow us to copy the database file, so to copy the database in Android I have to perform file write operation. So in Android I create a new database and perform write operation on it. You have to follow this for Android -

As a temporary fix I do this

Starting copy of database 1 ... waiting Database 1 signals successful, opening database 1 Starting copy of database 2 ... waiting Database 2 signals successful, opening database 2

However if you have any suggestion, then let me know.

s-pic commented 6 years ago

@mmp-schmitt

I have the about the same issue. Could you provide some code to show how you solved this?

an-rahulpandey commented 6 years ago

you cannot copy multiple databases at once in Android, you have to copy databases one by one. copy one database and then in the success callback of that function, copy the other databasae.