How to Make a Clean Architecture Note App (MVVM / CRUD / Jetpack Compose) - Android Studio Tutorial

Philipp Lackner · 359K views · 2021 · 2:23:59

Open on YouTube

Software architecture & designSoftware (other)Education & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it as a worked example of clean architecture, MVVM and unidirectional data flow in Jetpack Compose, and as the source of the note app code they are following.

Recommended by 2 people across 2 different months, 2022 to 2023.

What it is

A long, follow-along Android tutorial by Philipp Lackner that builds a CRUD note-taking app in Jetpack Compose using clean architecture and MVVM. It covers Room persistence, use cases, ViewModel events and Compose UI, with starter and final code on GitHub.

What people said

Recommends z.g.y · 2022-10 · Stack Overflow · on “@Composable invocations can only happen from the context of a @Composable function in android”

There's nothing wrong calling startActivity inside onClick , but you should NOT call the MainScreen's constructor (assuming it's an Activity ), you can simply remove the parenthesis and it will be fine. onClick = { if (password.equals("Abac@xi123")) { mContext.startActivity(Intent(mContext, MainScreen::class.java)) } } But I suspect MainScreen is just another @Composable screen and not an Activity that you want to navigate to and your'e having that error because you cannot call a composable inside non-composable functions like the compile error you are seeing. I would suggest further reading and especially watching the live coding, you will see first hand how to navigate from a composable sc

Recommends Sevban Bayır · 2023-09 · Stack Overflow · on “Jetpack compose Implementing unidirectional flow Datastore -> ViewModel -> UI”

Firstly, in your viewModel, in current code you're not updating your settingsUiState you should do something like: ...collect { data -> settingsUiState.update { it.copy(settingsDetails = data)} } Second, for your unidirectional understanding, i suggest you to take a look at this video [this video] video. It is actually very long video but you can obtain a very good understanding about unidirectional dataflow from it. Though, a takeaway would be We usually use callbacks and lambdas in compose, we generally do not pass viewModels, repositories or datastores (in your case) to down to our composable tree. Instead, we create lambdas or take them as parameters in our composables and at the top of our c

Cites Felipe Martins · 2023-04 · Stack Overflow · on “Why does @PrimaryKey val id: Int? = null works when creating a Room entity?”

I'm following a tutorial on how to create a note app using Jetpack Compose. This is the link for the tutorial [this video] . There is a point in the tutorial that he creates this entity: @Entity data class Note( val title: String, val content: String, val timestamp: Long, val color: Int, @PrimaryKey val id: Int? = null ) Please take note that he is using a nullable value for the primary key and that he is not using the (autoGenerate = true) . I would have thought that wouldn't work. First because the primary key should never be null and second because without the autoGenerate how will the id behave? Won't they all have the same id? The code I have seen more often when creating room entities is th

Cites Sevban Bayır · 2023-06 · Stack Overflow · on “How to refactor a very large Event Class in Jetpack compose”

I'm using a sealed class to classify user events and send to viewModel's onEvent function so that handle them but since I have some sort of form Composable in my screen's BottomSheet both my onEvent function which is in viewModel to handle events and PairDetailEvent class had very largen when app is scaled so I think it is a bad practice to have this large of sealed class and also that much branches in an onEvent function, so if there is a way or best practice to follow to maintain readability i wanna know that. I tried to apply practices in this [this video] video by the way Thanks in advance. PairDetailEvent class : sealed class PairDetailScreenEvent { data class SaveAnalyze(val pairId: String)

Cites Duffischer · 2023-08 · Stack Overflow · on “Android Room one to many relation data class throw's error "Entities cannot have relations"”

Disclaimer: I'm a complete beginner to Android development in Kotlin and just started some weeks ago. My goal is to create an Quiz App which gets it's Questions and Answers from a local, prepopulated Room database. SQLITE: The sqlite database has the following schema: sqlite> .schema CREATE TABLE quiz_questions(ID INTEGER PRIMARY KEY, question TEXT, quest_result INTEGER NOT NULL DEFAULT 0); CREATE TABLE quiz_answers(ID INTEGER PRIMARY KEY, quest_id INTEGER, answer TEXT, is_true INTEGER NOT NULL); => The quest_id is the foreign key which reflects the ID of the related question => One question has many answers (specifically 4 in my case) Links: I used the following guides to create my app and