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

copyDbFromStorage copy Db to wrong path in Android 9 #59

Closed mikulifourtechnolab closed 5 years ago

mikulifourtechnolab commented 5 years ago

@an-rahulpandey I found that problem with android 9 device, creating new database path to save DB on any operation

I using Cordova version : 6.4.0 Cordova-android : 6.1.0

android 9 save db to different path to save db i want to copy the database to new path created by android 9 feature.

I have used below code window.plugins.sqlDB.copyDbFromStorage("demo", 0, zippath + "demo", true, function (success)

1111111112123

i want to copy db to new location which android 9 to save db (copy demo -> to file_0->1)

Can you help me out

SwanGit commented 5 years ago

@an-rahulpandey @mikulifourtechnolab

On Android 7 the window.sqlitePlugin.openDatabase command, is operating on the "original" Db path: databases/demo/demo.db, while on Android 9 the openDatabase is opening the Db from new default Db path app_Webview/databases/file_0/1/demo.db

However the window.plugins.sqlDB.copyDbFromStorage command is still copying the demo.db to the same path in both Android 7 and 9 databases/demo/demo.db.

This mean that openDatabase can not access/do not find the demo.db database when in Android 9.

To being able to continue to use the cordova-plugin-dbcopy in Android 9, how can we make the copyDbFromStorage command copy the demo db to(when in Android 9): app_Webview/databases/file_0/1/demo.db ?

Alternatively if the the case is that the cordova-plugin-dbcopy is not Android 9 compatible, how is it possible to do a a manual file copy from:
databases/demo/demo.db to app_Webview/databases/file_0/1/demo.db ?

Please enlighten us if we are completely overlooking something in this case.

an-rahulpandey commented 5 years ago

Hi, @SwanGit @mikulifourtechnolab Thanks for figuring out the issue and giving a good insight on it. I will check it out as soon as possible.

how is it possible to do a a manual file copy from: databases/demo/demo.db to app_Webview/databases/file_0/1/demo.db ?

I don't think it will allow us to copy the file to db location as it might be protected directory.

SwanGit commented 5 years ago

@an-rahulpandey Thank you for quick reply, we really do like the cordova-plugin-dbcopy plugin, it offer such a great and required functionality, but it do need to be Android 9 compatible.

mikulifourtechnolab commented 5 years ago

@an-rahulpandey

I have used SQLite plugin "https://github.com/Telerik-Verified-Plugins/SQLite" (v_1.1.0) and upgraded "cordova-plugin-dbcopy" plugin from (v_2.0.0) to latest version (v_2.1.2) and now database copied to my actual path which i needed with android-9.

My issue got resolved by upgraded "cordova-plugin-dbcopy" plugin.

Thanks