1

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,

  1. 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?
  2. 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).
  3. Is it good idea to close in onStop()?
  4. 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?

Deepa Bedsur
  • 149
  • 1
  • 10

0 Answers0