an-rahulpandey / cordova-plugin-dbcopy

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

Does sqliteDbCopy run on Capacitor? error:400 #69

Open Miliziano opened 3 years ago

Miliziano commented 3 years ago

Hi to All and thank you for this plugin. But I think that it isn't compatible with Capacitor (Ionic permits the use of Capacitor).

My database file is correctly into www folder and my minSdkVersion is 26 (target is 29). Only last versions of Ionic, Capacitor and all other...

I use this snippet: _this.sqliteDbCopy.copy( "cappottofacile.db", 0) .then((res: any) => { ... open DB }) .catch((error: any) => { ... output for error });

My output is: _I/Capacitor/Console: File: http://localhost/pages-references-references-module-es2015.js - Line 201 - Msg: --Platform hybrid ready. V/Capacitor/Plugin: To native (Cordova plugin): callbackId: sqlDB282510492, service: sqlDB, action: copy, actionArgs: ["cappotto_facile.db",0] D/CordovaLog: DatabasePath = /data/user/0/io.ionic.starter/databases/cappotto_facile.db&&&& dbname = cappotto_facile.db&&&&DB Exists =false D/Cordova: Try Error = www/cappotto_facile.db D/CordovaLog: Inside CreateDatabase getAbsolutePath= /data/user/0/io.ionic.starter/databases/cappotto_facile.db Inside CreateDatabase path = /data/user/0/io.ionic.starter/databases/cappotto_facile.db D/CordovaLog: www/cappotto_facile.db E/Capacitor/Console: File: http://localhost/pages-references-references-module-es2015.js - Line 221 - Msg: --Database cappotto_facile NON copiato, message:www/cappotto_facile.db E/Capacitor/Console: File: http://localhost/pages-references-references-module-es2015.js - Line 222 - Msg: --Database cappottofacile NON copiato, codice:400

Could you help me? Thank you in advance. Marco

Miliziano commented 3 years ago

Debugging into Android I’ve found:

W/System.err: java.io.FileNotFoundException: www/mydatabase.db …

when plugin perform a : myInput = cordova.getActivity().getAssets().open(“www/” + dbName);

the file is in : …\project_name\android\app\src\main\assets\public\mydatabase.db

I still have to understand what this www folder means...

cheers

Miliziano commented 3 years ago

Solved! The www corresponds to public !

myInput = cordova.getActivity().getAssets().open(“www/” + dbName);

becames myInput = cordova.getActivity().getAssets().open("public/" + dbName);

and plugin runs on Android with Capacitor on Ionic5,

I change it into my Android project, but I suggest our friends to change it into the gitHub.

I'dont know if there are other differences among android versions...

Thank you to all. Marco

an-rahulpandey commented 3 years ago

Hi @Miliziano I'm glad you sorted this out. I am meaning to update the plugin for latest ionic with capacitor and cordova supports,, but not getting a chance. Will surely try to update it as soon as possible.

rizz360 commented 3 years ago

Hi @Miliziano I'm glad you sorted this out. I am meaning to update the plugin for latest ionic with capacitor and cordova supports,, but not getting a chance. Will surely try to update it as soon as possible.

Hi! Any updates on this? Is there a workaround for loading from the public folder instead of the www folder when using Capacitor for iOS?

Miliziano commented 3 years ago

Sorry, I dont know....yet. Marco

Il giorno mer 3 mar 2021 alle ore 09:35 Rizz notifications@github.com ha scritto:

Hi @Miliziano https://github.com/Miliziano I'm glad you sorted this out. I am meaning to update the plugin for latest ionic with capacitor and cordova supports,, but not getting a chance. Will surely try to update it as soon as possible.

Hi! Any updates on this? Is there a workaround for loading from the public folder instead of the www folder when using Capacitor for iOS?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/an-rahulpandey/cordova-plugin-dbcopy/issues/69#issuecomment-789538807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFP7A5B6JCQS2EQJZPYPZK3TBXYEXANCNFSM4UD7I4PQ .

--


Nota legale: I dati contenuti nel testo e negli allegati di questo messaggio e delle successive risposte sono di natura professionale e confidenziale, sono riservati esclusivamente ai loro destinatari e non potranno essere inoltrati o divulgati senza una formale autorizzazione da parte del mittente. Si rammenta che, all'interno delle organizzazioni del mittente e dei destinatari, le rispettive norme aziendali di riferimento non possono alleggerire le condizioni e i divieti qui esposti. Ogni ulteriore utilizzo/trattamento e' assolutamente vietato e la non osservanza di quanto sopra indicato deve considerarsi violazione di legge e puo' comportare il risarcimento del danno (art. 2043 c.c.), e la condanna penale di reclusione sino a tre anni (art. 616 c.p. e 167 d.lg. 196/2003).


daevst commented 3 years ago

any updates?

acosme commented 2 years ago

I've tested in Ionic 6 + Capacitor 3 + android 31, compileSdkVersion 30, targetSdkVersion 30.

Works well, doesnt need to change 'www' to 'public';