- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a APP with WebSQL. It works OK on Android build. Now I´m testing the same APP with Cordova build. There is on problem: the database of old version is lost when a new Cordova version is installed.
For this moment, according with the comments, I assumed that isn´t have a solution. Then, I am trying to prevent it for the next situation like that. The solution is the use of SQLitePlugin (I hope).
But, there is a situation that I need help (maybe it is only a javascript problem that I don´t know...). Today I have the OPENDATABASE at the initial part of the javascript (global) and the use of variable in any function. Something like this
var wTamanhoDB = 1 * 1024 * 1024; //10 Mb
var wDetalheDB = "APP ConfirmAki Pro";
var wNomeDB = "dbConfirmakiPro";
var wVersaoDB = "";
var db = window.openDatabase(wNomeDB, wVersaoDB, wDetalheDB, wTamanhoDB);
function x {
db.transaction(populateDB, errorCB, successCB);
}
function x {
...
db.transaction(populateDB, errorCB, successCB);
...
}
function y {
...
db.transaction(function(tx) {...}
...
}
function y {
...
db.transaction(function(tx) {...}
...
}
But, to use the plugin, I need to wait "deviceready", so, my "var db" is inside a function. It will be local. Then, all code must be changed, like this:
var wTamanhoDB = 1 * 1024 * 1024; //10 Mb
var wDetalheDB = "APP ConfirmAki Pro";
var wNomeDB = "dbConfirmakiPro";
var wVersaoDB = "";
function x {
var db = sqlitePlugin.openDatabase(wNomeDB, wVersaoDB, wDetalheDB, wTamanhoDB);
db.transaction(populateDB, errorCB, successCB);
}
function x {
...
var db = sqlitePlugin.openDatabase(wNomeDB, wVersaoDB, wDetalheDB, wTamanhoDB);
db.transaction(populateDB, errorCB, successCB);
...
}
function y {
...
var db = sqlitePlugin.openDatabase(wNomeDB, wVersaoDB, wDetalheDB, wTamanhoDB);
db.transaction(function(tx) {...}
...
}
function y {
...
var db = sqlitePlugin.openDatabase(wNomeDB, wVersaoDB, wDetalheDB, wTamanhoDB);
db.transaction(function(tx) {...}
...
}
Is it right? In every function I will open the database. Is it correct? There is another solution? Thank you.
- Tags:
- HTML5
- Intel® XDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Without knowing how the rest of your app is laid out, I would assume you could:
a) keep "db" as a global. Just define it is "var db" - it will be undefined.
b) open the database inside your device ready event and assign it to the db variable.
c) continue to use your "db.transaction" calls as-is. You could do an "undefined' check on db if the functions might be invoked before your device ready.
If this was too brief, let me know. You could do a lot more with this, and I personally would, but I tried to describe the minimal level of change in relation to the code you posted.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Without knowing how the rest of your app is laid out, I would assume you could:
a) keep "db" as a global. Just define it is "var db" - it will be undefined.
b) open the database inside your device ready event and assign it to the db variable.
c) continue to use your "db.transaction" calls as-is. You could do an "undefined' check on db if the functions might be invoked before your device ready.
If this was too brief, let me know. You could do a lot more with this, and I personally would, but I tried to describe the minimal level of change in relation to the code you posted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend you use this plugin https://github.com/brodysoft/Cordova-SQLitePlugin since it uses a native implementation so that means it is part of the native app data, so your database should stick around for updates to your app.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great! It works! And this version (Cordova Crosswalk) is faster than. All user operations is smarter. Only the size of the APP is huge... I will send to some users to test before publish it on Google Play. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad to hear it is working. Thanks Paul for the useful clarification on the recommended plugin. Crosswalk is awesome but it does definitely bulk up the app. I think it's well worth the trade-off myself, hopefully your users agree.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We're working on ways to reduce that size issue, but I do believe that the additional size (due to the included webview) far outweighs the alternative of making every Android native webview work! Please put both versions of the Crosswalk image into the store, so their is an x86 and an ARM image available for all devices. If you do not then you'll get some people that download an ARM image onto an x86 device and things will not work properly for them. The versionCode has been designed to make this process transparent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
" I do believe that the additional size (due to the included webview) far outweighs the alternative of making every Android native webview work!"
Couldn't agree more. Having a single target for Android makes for much, much more pleasant development.
I realized rereading my last messages the "hopefully your users agree" may have appeared it was directed at Intel. I mean that I hope Hamilton's users aren't bothered by the file size.
Now if you could just "crosswalk" iOS. LOL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both about the comments. I need to resolve only one issue before publish this APP as Crosswalk on Google Play (https://software.intel.com/en-us/forums/topic/542976). I think that performance will be well received by users.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page