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.isOpen() #700

Closed
cherrydev opened this issue Jun 9, 2017 · 5 comments
Closed

Database.isOpen() #700

cherrydev opened this issue Jun 9, 2017 · 5 comments
Milestone

Comments

@cherrydev
Copy link

It would be great if the Database interface exposed the .isOpen() method of the delegate. I'm dealing with an app that uses AccountManager and has separate databases for each user. When an account is deleted, a callback deletes the underlying database, but if the app is still running, when my Activity resumes it needs to check if the database is still open. I can do it by getting the raw database and then casting it (to one of two implementation classes, depending on if it's encrypted or not) but it seems like adding .isOpen() to the interface should be straightforward.
I'd be happy to submit a pull request for it if the idea is approved. Thanks.

@greenrobot-team
Copy link
Collaborator

greenrobot-team commented Jun 12, 2017

@cherrydev The built-in StandardDatabase and EncryptedDatabase always return a SQLiteDatabase for Database#getRawDatabase. So you should be safe to cast to SQLiteDatabase and call isOpen() on it. -ut

@greenrobot-team greenrobot-team self-assigned this Jun 12, 2017
@cherrydev
Copy link
Author

There are two SQLiteDatabase classes in two different packages, one for the standard, one for the encrypted. There is no common interface or subclass for these two SQLiteDatabase classes. Therefore a single call to isOpen() requires code for two instanceof expressions and two casts. The Database interface has a close() method on it. Why not isOpen()?

@greenrobot-team
Copy link
Collaborator

Sorry, I missed the different package for SQLiteDatabase. Suggested a change. Thanks! -ut

@cherrydev
Copy link
Author

Thanks!

@greenrobot-team greenrobot-team removed their assignment Jul 17, 2017
@greenrobot-team greenrobot-team added this to the 3.x milestone May 7, 2018
@greenrobot-team greenrobot-team modified the milestones: 3.x, 3.3.0 Feb 18, 2020
@greenrobot-team
Copy link
Collaborator

3.3.0 has been released which includes the above change.
https://greenrobot.org/greendao/changelog/

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

2 participants