In most Android database examples, SQLiteOpenHelper is extended and contains information to create and update the database. However, in many examples the helper class contains methods to add, delete, and return records. My question is would it be better to include these CRUD methods in the class that extends SQLiteOpenHelper, or would it be better to create a separate class with an instance field of the class that extends SQLiteOpenHelper, which contains all the CRUD methods? Would this just be a personal choice, or are there other issues I may be overlooking? I feel like creating a separate class may be better form. I appreciate anyone's feedback.
Asked
Active
Viewed 617 times
3
-
Really depends on the size/complexity of your database. Can you elaborate? – pjco Oct 20 '12 at 23:14
1 Answers
0
The code that creates/updates the database must know about the database structure, so it makes sense to put the other code that knows about the database structure into the same class.
The resulting is not only about opening, so instead of MyOpenHelper
, call it MyDatabaseHelper
. :)

CL.
- 173,858
- 17
- 217
- 259