In this video, learn how the @Database annotation works. See how it connects the various entities together, and review the generated code created by Room.
- [Instructor] Let's define our RoomDatabase class.…This class is required by Room…in order to generate our SQLite database…and associated tables.…So we're gonna start by creating a class…that extends the RoomDatabase abstract class…and we're gonna do that here inside of our DB package…so we're just gonna Command + N and create a new class…and we're going to name this TopsyTurveyDatabase…and we can click on OK.…And as I mentioned,…this is going to extend the RoomDatabase class…and we're going to make this class abstract…so we'll just add that here on line five.…
And you wanna think of this particular class…as a container class because the Room compiler…is actually going to generate…a concrete implementation of it…which we'll look at momentarily.…So like most things with Room,…this class is going to require an annotation…and that is the @Database annotation…so we'll add that here on line five…and then we're going to supply it with some information.…So the first thing it needs is a list of entities…that are going to be contained inside of our database.…
Author
Updated
5/24/2018Released
5/5/2017To begin, Annyce Davis reviews using the de facto data persistence solution available on Android: SQLite. She takes you through basic SQLite concepts—such as how to create a database wrapper and insert data into a table—as well as a few more advanced topics. Next, she covers working with Cupboard, an open-source project dedicated to simplifying your SQLite interactions. To wrap up, she dives into working with Realm, an object database solution designed with mobile devices in mind. Throughout the course, Annyce discusses establishing relationships between database tables, creating and running queries, as well as performing data migrations.
- Overview of SQLite
- Defining a database table's schema
- Exploring SQLite create table syntax
- Executing create table statements
- Inserting data with a foreign key relation
- Inspecting the database using a terminal
- Updating and deleting records
- Working with Cupboard
- Working with Realm
Skill Level Intermediate
Duration
Views
Q: This course was updated on 05/24/2018. What changed?
A: New videos were added that cover working with Room.
Related Courses
-
Android App Development: Unit Testing
with James P White2h 58m Intermediate -
Learning Firebase Cloud Messaging for Android
with Joe Marini52m 49s Intermediate
-
Introduction
-
Welcome1m 50s
-
What you should know1m 12s
-
Review the starting app3m 3s
-
-
1. SQLite Basics
-
Overview of SQLite4m 17s
-
Create a database wrapper8m 49s
-
-
2. SQLite Beyond the Basics
-
Explore SQLite queries3m 11s
-
Query data using a raw query7m 19s
-
Delete records from a table7m 21s
-
3. Working with Room
-
Overview of Room4m 11s
-
Defining database entities6m 30s
-
Defining a Room database6m 8s
-
Create a data access object3m 55s
-
Insert data into a table6m 14s
-
Explore Room queries3m 30s
-
Create a schema migration5m 51s
-
-
4. Working with Cupboard
-
Overview of Cupboard4m 25s
-
Define a database schema9m 9s
-
Insert data into a table3m 24s
-
Update records in a table6m 20s
-
Create a schema migration7m 25s
-
-
5. Realm Basics
-
Introduction to Realm2m 57s
-
Configure a Realm instance5m 10s
-
Create a Realm object class5m 35s
-
Insert data into Realm5m 59s
-
-
6. Realm Beyond the Basics
-
Explore Realm queries5m 6s
-
Query Realm objects7m 58s
-
Explore Realm updates2m 26s
-
Update Realm objects5m 19s
-
Delete Realm objects5m 52s
-
Explore Realm migrations3m 36s
-
Create a schema migration7m 19s
-
Conclusion
-
Next steps43s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Defining a Room database