I read lot of about this topic but no solution can be used in my application.
Suppose there are few services and lot of activities that need to access db.
Of course only one activity is active. But in the worst scenario there is one activity and two services running background accessing db.
So when I close db from activity’s onResume – service accessing db would throw exception.
And same is when I close db from service’s onDestroy and there is opened cursor in activity.
I hold some kind of DBManager in my application object as singleton. I init DBManager in Application.onCreate. But there is no place to close db without risking that another Service and activity is accesing this.
So now I never close DB – are there any consequencies doing that?
Is there same simple(or not too complicated) solution to close DB?
here are my applications in market
I do the same, I use a singleton database object and never close it until my application is destroyed. I didn’t notice any issues so far. A more detailed answer is here:
https://stackoverflow.com/a/4842251/448625