mercredi 3 février 2016

What sequence of SQLite queries would restore my App state?

No matter how hard I rack my brain, I can't seem to figure this out. Probably because I am a beginner at handling databases.

Below is the database schema for my android app:

enter image description here

Now when my app starts up, the initializations for all my tabs and my activity are called immediately, before the user even selects an option to start a new checklist or resume a current checklist. Since this is the way my app is programmed, I'm thinking I need to take an approach of something like this when my app starts up:

  1. Check if the checklist table is empty (first ever app launch)
  2. If it is empty, insert data for a new checklist, dont have to restore anything
  3. If it is not empty, find the latest checklist_id
  4. From the checklist_id, somehow find what checklist_items/vitals/notes correspond to each tab for that checklist_id
  5. Somehow retrieve the set of checklist_items/vitals/notes for each tab
  6. Restore the states based off the information I retrieved

Now, I may be thinking of this completely wrong. Also, I am very confused on what queries I would need to retrieve the information about each item (checklist_item, vital, note) corresponding to each tab (5 tabs in my app) for the latest checklist_id.

Aucun commentaire:

Enregistrer un commentaire