Reputation: 131
i am looking for good practises about databases in android, my questions are :
1- should i close the database in every activity or close it in the last activity ?
2- i did many methods of insertions in every activity, so what are the possible problems that
i could encounter ?
3- i have only one classe for database , whish i create three tables, and in the same classe
i have about twenty methods of insertion, it is a good thing to do ?
thanks for answering :)
Upvotes: 1
Views: 132
Reputation: 1963
You always want to close your cursors once the data is read. I would suggest using ContentValues .put() method to insert new values into your DB.
No, multiple insertions should be OK, as long as they're sequential.
ORM Programming would suggest that you have a unique POJO (Plain Old Java Object) class for each table.
I would suggest keeping your Data and UI portions separate, using classes and methods to act as a mediator between the two. Of course, this is all just common Java 3-Tier programming knowledge.
Upvotes: 1