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 ... |
Get Hello, Android, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.