I just read large amount of relating to this subject but no solution may be used during my application. Suppose you will find couple of services and large amount of activities that require to gain access to db. Obviously just one activity is active. However in the worst scenario there's one activity and 2 services running background being able to access db.
Then when I close db from activity's onResume - service being able to access db would throw exception. And same happens when I close db from service's onDestroy and there's opened up cursor in activity.
I hold some type of DBManager during my application object as singleton. I init DBManager in Application.onCreate. But there's room to shut db without jeopardizing that another Service and activity is accesing this.
Now I never close DB - what are the consequencies doing that? Can there be same simple(or otherwise too complicated) means to fix close DB?
listed here are my programs in market
You should attempt using [cde], the Android system will handle creating/opening/closing the database as it must.
I actually do exactly the same, I personally use a singleton database object rather than close it until my application is destroyed. I did not notice any issues to date. A far more detailed response is here: