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:

     com.journaler.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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.