‫The third step in creating our room database is to create the database class.
‫The database class is an abstract class that serves as the database holder.
‫It includes methods to access the daos and create a database instance.
‫Let's create this database class and I'll name it as contact database.
‫You annotate the database class with the Add database annotation and specify the list of entities it
‫includes and the database version.
‫Since our application has only one entity class one table called context table, I need to specify it
‫here.
‫So entities equal to and here I need to specify it inside a list.
‫But since our application has only one entity table, I need to specify it here as only entity contacts
‫dot class and I'll specify the version equal to one later on.
‫When you update your database, you need to increase this number.
‫I'll create it as an abstract, as mentioned before, to prevent any possible creation of this class
‫so you prevent possible creation of objects extends.
‫And here I need to tell Android studio that I need to extend from the room database so this class will
‫act as a database instance using the annotation, add database and extending room database from Android
‫X room package.
‫So in order to understand it better, you need to create a class extending from room database.
‫And it's an abstract class and annotated with database and you specify the entity.
‫So you are linking this database with the entity.
‫Now we need to link this database with the Dao.
‫So for that I'll create a method that returns a contact Dao Public Abstract Contact Dao object.
‫It's returning type and get contact Dao.
‫This is a method named as get contact Dao.
‫Then it's returning type is as contact Dao class.
‫Here I am linking this database with Dao by using this method.