Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does sqliteDbCopy run on Capacitor? error:400 #69

Open
Miliziano opened this issue Nov 26, 2020 · 7 comments
Open

Does sqliteDbCopy run on Capacitor? error:400 #69

Miliziano opened this issue Nov 26, 2020 · 7 comments

Comments

@Miliziano
Copy link

Miliziano commented Nov 26, 2020

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( "cappotto_facile.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 cappotto_facile NON copiato, codice:400

Could you help me?
Thank you in advance.
Marco

@Miliziano
Copy link
Author

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
Copy link
Author

Miliziano commented Nov 27, 2020

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
Copy link
Owner

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
Copy link

rizz360 commented Mar 3, 2021

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
Copy link
Author

Miliziano commented Mar 3, 2021 via email

@daevst
Copy link

daevst commented Apr 8, 2021

any updates?

@acosme
Copy link

acosme commented Mar 17, 2022

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants