This is part of the "Android Data and Networking" learning path. View Path

Room Database: Getting Started

Aug 27 2020 · Video Course (1 hr, 52 mins) · Beginner

Covers loads of cool concepts in local data persistence, using the Room database on Android. Learn how to use Entities, Queries, Relations, Kotlin Coroutines, Type Converters, and database Migrations to develop a complex and wholesome app.

5/5 6 Ratings

Version

  • Kotlin 1.3, Android 10, Android Studio 3.6

Set Up The Room Database

Introduction

2:42 Free

Learn what Room is, why it's useful to have local databases, and what you'll cover throughout this course.

1

Set up the project, take a look at the final application, and add needed dependencies for the app.

2

Create your first Room Entity, add it to a basic Room database, and learn about the Entity and PrimaryKey annotations.

3

Practice using Room entities by creating more entities for the project and adding them to the database.

4

Write DAOs

3:04

Learn what Data access objects are, how to implement them, and how to connect DAOs to Room.

5

Practice creating data access objects in a small challenge. Add remaining DAOs to the app, and connect them to the Room Database.

6

Learn how to abstract away the database behavior by implementing another layer of communication, through the Repository pattern.

7

Conclusion

1:30

Review all the concepts learned in the first part of the course, and prepare for the second part, where you'll implement queries.

8

Make Queries

Learn more about data access objects and queries. Learn what kind of queries you can write, and what their implementation looks like.

9

Write your first few Queries, then learn how to fetch data from the database, and how to write queries to insert data.

10

Practice writing and using queries in a fun challenge! Finally insert data into the database, to pre-populate the database.

11

Learn how to write different types of queries, to add more functionality to the app.

12

Practice writing more queries, to add even more functionality to the app, in a fun challenge!

13

After storing some data in the database, learn how to explore the database, using a third party database browser tool.

14

Conclusion

1:34

Review the concepts you covered in this part of the course, then find out what's up next!

15

Define Entity Relationships

Learn what relationships are, and which types exist. Learn how to implement them, and about some examples of relationships.

16

Learn how to use the Embedded and Relation annotations, and how to create one-to-one relations between Books and Genres.

17

Extend your knowledge of relations to build a one-to-many relation between a genre and books by that genre.

18

Practice using relations, to implement another use case, and combine the Review and the Book entities into a single structure.

19

Conclusion

2:16

Review the concepts you've learned about relationships and combining multiple entities, and prepare for the next part.

20

Use Coroutines With Room

Learn about Kotlin Coroutines, and the Flow API, and why it's important to avoid blocking the main thread.

21

Use the coroutines API to implement a few suspending function calls to the database, to offload the main thread.

22

Practice suspending functions with Room queries, to fetch data asynchronously.

23

Use the Kotlin Flow API to return a reactive stream from the database, and receive updates every time you add or remove an entry.

24

Practice using the Kotlin Flow API, and add more reactive streams to database queries, to receive updates from the database.

25

Conclusion

1:24

Wrap up this part of the course, by reviewing all the concepts you've learned about Kotlin Coroutines.

26

Use Complex Types & Migrations

Learn about using complex types in Room with TypeConverters, and about migrating the database between different versions.

27

Learn what TypeConverters are, how to use them, and what their functions have to be written as.

28

Fix the problems with changed database schema, using a database migration. Learn what migrations are, and how to write them.

29

Learn how to store even more complex types of data, such as lists of objects. Migrate the database once more.

30

Practice using TypeConverters to store lists of data, implement a third migration for the database.

31

Conclusion

3:01

Congratulations on reaching the end of the course! Review all the concepts you've learned, and find out where to go next.

32

Who is this for?

Android developers looking to extend their app's functionality, by adding a way to persist data, using a local database.

Covered concepts

  • Room basics
  • Setting Up Room
  • Data Access Objects - DAOs
  • Queries
  • Entities
  • Primary keys
  • Relations
  • Embedded entities
  • One-to-one relations
  • One-to-many relations
  • Many-to-many relations
  • Complex queries
  • Query comparisons
  • Kotlin Coroutines
  • Room suspend functions
  • Room & Kotlin Flow
  • Complex Room types
  • TypeConverters
  • Gson parser
  • Room Migrations
  • Destructive migrations
  • Migrations between versions

Contributors

Comments