I have a ListView in my activity that is populated from a database Cursor using a SimpleCursorAdapter. The user can choose to edit/delete data items in the database from what he is shown in the ListView. Should I just keep a persistent database connection throughout this entire activity or would it be better to open/close a db connection whenever the user wants to edit/delete something?
Share
I would go with open/close the database when the activity resumes/pauses, although your latter alternative is also fine.
For me is closing when the user’s done with editing the whole list, and not when the user’s done with a specific item. Better performance-wise? Well, that depends on the size of your database.