Creating Your Application's SQLite Database

The Task Reminder application needs a place to store and retrieve the user's tasks, and the best place for this kind of information is inside an SQLite database. Your application needs to read, create, update, and delete tasks from the database.

image The Create, Read, Update, and Delete actions are known as CRUD operations — each letter standing for its respective action.

Understanding how the SQLite database works

The two activities in the Task Reminder application need to perform various duties on the database to operate. ReminderEditActivity needs to do the following:

  • Create a new record.
  • Read a record so that it can display the details for editing.
  • Update the existing record.

The ReminderListActivity needs to perform these duties:

  • Read all the tasks to display them on the screen.
  • Delete a task by responding to the click event from the context menu after a user has long-pressed an item.

To work with an SQLite database, you must communicate with SQLite through classes in the android.database package. Because common practice is to abstract as much of the database communication away from the Activity objects as possible, the database mechanisms are placed into another Java file (and usually a package if the database portion is quite large) to help separate the application into layers of functionality. Therefore, if you ever need to alter ...

Get Android™ Tablet Application Development For Dummies® now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.