‫Hello, my friends.
‫In the previous videos we've created our layouts for the fragments and the menus.
‫In this video, we will start building our Mvvm architecture.
‫We will start with the room database, then repository ViewModel and the activity.
‫Now.
‫We will start, as usual with the room database.
‫And the first thing we need to create is the entity class.
‫So entity.
‫In this video, we will create a new class called Node that will act as an entity class for our room
‫database and as a modal class.
‫Let's jump into Android studio and start building our database.
‫I've moved the.
‫Fragments into a new package called fragments.
‫And don't miss too.
‫Create a new package with small letter.
‫New package, I will create a new package called modal.
‫Inside this modal package, I will create a new Kotlin class and I will create it as note.
‫And I will select data class and click Enter.
‫And here we go.
‫This is our data class.
‫And as usual, as we learned before, I need to annotate it as entity in order to understand and allow
‫the Android studio to to recognize that this class will act as an entity class for our room database.
‫Here I need to specify the name of the columns that I need to make, and here I can specify the table
‫name or if I don't specify it, it will create a table with a note.
‫Here exactly like this class.
‫So I will name the table as notes here.
‫The data class.
‫Note I will start with the val ID.
‫It's of type integer.
‫The second variable will be note title.
‫And this is the second column name.
‫The Val.
‫Note body is of type string.
‫Okay.
‫In order to specify the column primary key, which is the ID, I need to add an annotation at primary
‫key.
‫Here you can specify that the ID will act as a primary key.
‫If you need to create a column name that's different from node title name.
‫You can specify add column info and specify the name of your new column.
‫But I prefer using this and change the column name from here without using Make it complex.
‫Now I want to lecture a new thing that I've.
‫I've didn't mention it before, which is the part syllable.
‫So I will add parse syllable here.
‫From Android OS and I will add at parse lies.
‫Annotation, which is from Kotlin dot personalize dot, personalize class.
‫But first what it is.
‫The past syllable and why we need to to add them and how to add the dependency for the past syllable.
‫First, let's talk about PA syllable.
‫PA syllable is an interface that a class can implement to be passed within an intent from an activity
‫to another one.
‫This way transporting data from one activity to another one.
‫By default PA syllable will will need to override two functions that describe contents, function and
‫write to parcel.
‫So if I put like this PA syllable, I need to override two functions.
‫Describe content.
‫Contents and right to parcel label.
‫But thanks for Kotlin.
‫We don't need to override these methods.
‫We can directly use parcels to handle this with minimal code so I can remove this.
‫Part syllable.
‫And I can use the personalize annotation in order to add that to in order to minimize the usage of the
‫scribe contents method and write to parcel method.
‫Okay, but we need to add the personalize annotation.
‫So this personalize annotation will tell an Android and Android studio and the Kotlin compiler to generate
‫a write to parcel and describe contents method methods as well as creator factory class automatically.
‫So despite writing this methods, we're going to use the personalize annotation in order to get rid
‫of these methods and override them here automatically.
‫But first, how to add the personalized annotation.
‫Library.
‫Of course, we will go to the official and developer.android.com slash Kotlin slash personalize.
‫And we need to search for this personalize.
‫I need to apply the Kotlin ID.
‫Here inside the cradle.
‫And under this I will pass like this.
‫Sync now.
‫And if there is any dependency, I need to add.
‫I don't think so.
‫So wait for bold.
‫For the gravel and this annotation will be solved automatically.
‫And here we go.
‫We have this error alt plus enter to import the parcels.
‫And I will select.
‫Kotlin x dot partials.
‫Dot partials annotation.
‫So this is our.
‫Note entity class which acts as modal inside.