‫Welcome back.
‫We finished the entity and the Dao parts.
‫Now let's move to the database part.
‫I'll start by creating a new Kotlin class and I'll name it as Contact Database.
‫Click enter and this class will act as a room database.
‫I'll annotate it with at database annotation that add database annotation is used to declare a class
‫as a room database and configure its properties.
‫It takes two parameters the entities and the Virgin.
‫I'll start with entities equals to contact class entities is an array of entity classes that represents
‫the tables in the database.
‫In this case there's a single entity which is the contact.
‫Did you remember the contact class that we created before.
‫So only we have this table in our database I need to specify it here in the entities parameter.
‫The second parameter is the virgin.
‫Here I need to specify an integer that represents the virgin of that database.
‫If you make a changes to the database schema, you may need to increment the Virgin to trigger a migration.
‫And to tell Android Studio that this class will be a room database instance, we need to extend it from
‫the room database instance.
‫Also, I need to make it as an abstract to prevent any creation of instances of this class.
‫And here we go.
‫Now we're able to use it as a room database.
‫You would typically define the data access objects the Dao as abstract methods.
‫Within this class, DAOs are responsible for defining the methods that interact with the database.
‫I'll start with abstract val.
‫You can create it as a function.
‫Contact dao.
‫I'm creating an instance from it.
‫In the next video we're going to continue with the database.
‫And we're going to introduce the singleton design pattern.
‫And we're going to learn how to create only one instance of contact database in our application.