O'Reilly logo

Android™ Tablet Application Development For Dummies® by Donn Felker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required