I want to build a fairly simple Android application.
The basic data model of my app consist on several basic elements with relationships between them.
I want the data to be persistant so I’m thinking about using an sqlite DB.
I looked at the Android Developer website, and the closest thing that I could find that is relevant to my question is the “NotePad Tutorial” which make use of an sqlite DB to store notes.
I think by now I got the handle on the basics, but I still have some questions though:
- In the tutorial they have only one table in the DB. If my application requires a more complicated scheme – should I still use the same method? that is – putting everything inside a subclass of
SQLiteOpenHelper? Or is there a more “structured” way to go? - Should I bother creating classes for all the data elements stored in my DB? I mean this is what I learned that I should do, but in the documentation there is no hint about that.
- If I Should create classes – How should I use them correctly? I mean, since the result of the query is a
Cursorobject, and not a collection of rows, Should/Can I parse that into objects?
Thanks!
Define all the tables in the same subclass, this makes easy to see all the table at one place and possibly write SQL for upgade etc
Yes, that would be easier for manipulation in the java side and makes code clean
Read from the cursor and initialize an arraylist of objects one by one.