I get the database connection whenever I have to perform some operations on the DB like insert row, delete row, update row and query from SQLite persistence layer which extends SQLiteOpenHelper.java.
I am closing the database when I delete the DB for resetting the app data.
Few doudts,
- Is it fine to close the database once the DB is deleted? How to check application is using how much battery and CPU because of DB connection is open?
- Is it good idea to close the DB onDestroy() of all the activities in the application? But onDestroy() may not be called when app is killed(http://developer.android.com/training/basics/activity-lifecycle/stopping.html).
- Is it good idea to close in onStop()?
- Closing on onPause() will be problem because there will many activities will be open and closed.So it closes many times.Will it be performance problem?
With all this information i searched getting confused what to do now?