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

Move from std api to sqlite #18

Closed
luigi37 opened this issue Apr 17, 2017 · 6 comments
Closed

Move from std api to sqlite #18

luigi37 opened this issue Apr 17, 2017 · 6 comments

Comments

@luigi37
Copy link

luigi37 commented Apr 17, 2017

Hi. Is it possible to open with this plugin a dB on Android cordova already created with native method?

@brodybits
Copy link

If you create a database on Android using the standard android.database API you can open the database using the Cordova plugin. But you have to watch for possible "Multiple SQLite problem" documented in storesafe/cordova-sqlite-storage#626 (with a few edits):

From http://ericsink.com/entries/sqlite_android_n.html: in case someone uses android.database.sqlite from another plugin or application-specific Java code to access the same database as this plugin at the same time there is potential for database corruption ref:

Note that the first part about "SQLite and Android N" is NOT a problem with this plugin since it uses its own build of SQLite.

In case anyone encounters this issue the workaround is to open the database with the androidDatabaseImplementation: 2 and possibly androidLockWorkaround: 1 settings as documented.

@luigi37
Copy link
Author

luigi37 commented Apr 20, 2017

Thanks Chris. So I need just to be carefully about concurrent calls, right? Only my app is accessing this db so I assume that I can swap flawless to the plugin as long as I'm sure no other call is made by std API.
Thanks for confirming

@brodybits
Copy link

So I need just to be carefully about concurrent calls, right?

Yes. To be on the safe side I recommend that you avoid having the database open in only both the plugin and your code using the std API.

Note that this would NOT be an issue if you use androidDatabaseImplementation: 2, possibly with the androidLockWorkaround: 1 setting as documented.

@luigi37
Copy link
Author

luigi37 commented Apr 20, 2017

Thank you Chris.
I will put those parameters in and test.
Very last point... will this plugin work even in the (hopefully unlikely) event that Android and iOS drop websql support?
Thanks
Luigi

@brodybits
Copy link

Very last point... will this plugin work even in the (hopefully unlikely) event that Android and iOS drop websql support?

Absolutely and this is definitely an advantage of using the plugin.

Another tip is that in case you make in app in Cordova then decide to rewrite it as a native app you can continue to use the same database. This should also work if you decide to switch to React Native as well.

@luigi37
Copy link
Author

luigi37 commented Apr 20, 2017

That's absolutely OUTSTANDING!
Thanks a lot Chris!
Luigi

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

No branches or pull requests

2 participants