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

Database not closing on Android #150

Closed
vtenext-dan opened this issue Oct 28, 2014 · 6 comments
Closed

Database not closing on Android #150

vtenext-dan opened this issue Oct 28, 2014 · 6 comments

Comments

@vtenext-dan
Copy link

I was experiencing a problem on Android platform, when closing the database. This caused problems in my app, since in some cases I needed to reload the page, and to prevent opening the same database multiple times, before the reload I was closing the DB. Unfortunately this seemed not to work and in logcat I had:

sqlite returned: error code = 5, msg = database is locked, db=/data/data/[APP-ID]/databases/webview_db
sqlite returned: error code = 5, msg = database is locked, db=/data/data/[APP-ID]/databases/webview_db
CREATE TABLE android_metadata failed
Failed to open the database. closing it.
android.database.sqlite.SQLiteDatabaseLockedException: database is locked
... and so on ...

The issue seemed to be in the run() method of DBRunner:

dbrmap.remove(dbname); // (should) remove ourself

closeDatabaseNow(dbname);

Here, first the mapping with the db name is removed and then the database connection closed. But the closeDatabaseNow method uses that mapping to retrieve the database object, and since it has been removed, nothing is returned and the database is not closed.

The solution was simple: I just switched those rows and the database was closed correctly.

I hope this can help someone

@brodycj
Copy link
Contributor

brodycj commented Oct 30, 2014

+1 will make this fix sometime later thanks @magikozio

brodycj pushed a commit that referenced this issue Mar 10, 2015
Fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)

Testing ONLY:
- #147: testing with UNICODE line separator
- #195: Reproduce issue with double-precision REAL number on WP(8) ONLY
brodycj pushed a commit that referenced this issue Mar 10, 2015
Fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)

Testing ONLY:
- #147: testing with UNICODE line separator
- #195: Reproduce issue with double-precision REAL number on WP(8) ONLY
@brodycj
Copy link
Contributor

brodycj commented Mar 10, 2015

The fix has been published.

@brodycj brodycj closed this as completed Mar 10, 2015
brodycj pushed a commit that referenced this issue Mar 10, 2015
Related to the following fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)
@brodycj
Copy link
Contributor

brodycj commented Jun 1, 2015

@durgaprasadp I am very sorry but this is not enough information to help you and from the log, I can see that you are using an old version of the plugin. Also, this issue was regarding a small fix that was needed in the past. The fix has been applied and this issue is now closed.

Please upgrade to use the latest version of this plugin. If you are still having problems, please do the following:

  • Please make sure you are using the latest version. Older versions are normally not supported.
  • Isolate the smallest test program that you can make to reproduce your problem
  • Raise a new issue and post the entire test program where you see the issue.

@brodycj
Copy link
Contributor

brodycj commented Jun 1, 2015

@durgaprasadp can you try opening the database with androidDatabaseImplementation: 2 as described in README.md and try it again?

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

3 participants
@brodycj @vtenext-dan and others