This title may sound a little bit crazy, but this is what is making me confused. My app heavily uses local database operations. As suggested in the Android docs and some blogs, I extended the SQLiteOpenHelper
class and defined all my DB operations there. As some of my DB operations execute in threads, opening and closing of the db causes some IllegalStateExceptions
. So, I made my DB helper as Singleton
and it resolved those issues, also getting rid of the open
and close
operations for every DB action. Now everything seems to be working fine even though I never close the DB.
- My confusion is that is it necessary to close DB?
- If so, what is the right place to do so, is it in
onDestroy
of the main activity or somewhere else? - If I don't close DB, what are the side effects?