Brejuro
Brejuro

Reputation: 3541

High level design for holding state in android app

I'm looking for some incite on how I can hold a state for my android app:

My app is a checklist app where the user can create a New Checklist from the Main Menu, in which it will bring them to an Activity that control 4 Fragments (each of which is a section of my checklist). I'm trying to figure out how I can hold a state so that when the user creates a new checklist and navigates to the main menu, when they RETURN to the checklist, everything is how it was before.

Upvotes: 0

Views: 204

Answers (2)

JDenais
JDenais

Reputation: 3016

I think your best shot is to create a local database to store all your checklists. Access is really fast so your user won't notice anything. The only down side is the work needed to update the database design after you released your app.

Android uses SQLite. There are many tutos available.

Edit: The way you describe your app, I suggest you create at least one table for the checklists and on table for the tasks.

Checklist would have columns for : _id , name, tasks_count, creation_date, last_edition_date, importance, due_date, all_complete

Tasks would have columns for: _id, checklist_id, name, description, date_created, date_completed, importance, due_date

My advice to you is to create more columns than you need at first. Design your database for features to come in the future, even though you may never implement them. There is nothing more painful than changing the design of your tables many times during dev and even worse after deployment.

Upvotes: 1

Acapulco
Acapulco

Reputation: 3533

If your checklist is simple enough you could use Android's SharedPreferences.

You could save a list of strings. This is much easier than using SQLite however it's obviously much less flexible and it's not designed for big objects.

If you plan to do anything more complex then you are better off with SQLite

Upvotes: 1

Related Questions