O'Reilly logo

Hello, Android, 4th Edition by Ed Burnette

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

Hello, Database

To demonstrate SQLite, let’s create a little application called Events that stores records in a database and displays them later. We’re going to start simple and build up from there. Open a new “Hello, Android” program using these values in the project wizard:

 
Application name: Events
 
Company Domain: example.org
 
Form factors: Phone and Tablet
 
Minimum SDK: API 16: Android 4.1 (Jelly Bean)
 
Add activity: Blank Activity
 
Activity Name: MainActivity
 
Layout Name: activity_main
 
Title: Events

As always, you can download the complete source code from the book’s website[81] (look for the eventsv1 example).

We need somewhere to hold a few constants describing the database, so let’s create a Constants interface:

eventsv1/src/main/java/org/example/events/Constants.java ...

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