Describing our database

First thing we will do is describe our database by defining its tables and columns with proper data types. We will also define simple models that will represent our data. To do so, create a new package called database:


Then, create a new Kotlin class called DbModel. The DbModel class will represent the matrix for all database models of our application and will contain only the ID, since the ID is a mandatory field and will be used as a primary key. Make sure your DbModel class looks like this:

    package com.journaler.database 
    abstract class DbModel { 
      abstract var id: Long 

Now, when we define our starting point, we will define data classes that will actually contain data. Inside our existing ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.