ROOM Database - #4 Update Data | Android Studio Tutorial
HTML-код
- Опубликовано: 30 июл 2024
- 🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
stevdza-san.com
🐱👤 Wanna become a member? Join!
/ @stevdzasan
📸 Instagram
/ stevdza_san
Hello there and welcome to my Tutorial Series. With this video I'm starting a new tutorial series about ROOM database with Kotlin. This tutorial serie will have 5 videos.This current video will be all about updating our items in database. So if you watched my earlier tutorial series about SQLite Database, then you noticed how hard is it to create and manage one database. But with ROOM library everything is easier! ROOM library is built on top of SQliteOpenHelper class.
Project File (Part 4): drive.google.com/file/d/1OgrA...
Room Database Part 1 - Create Database Schema - • ROOM Database - #1 Cre...
Room Database Part 2 - Insert Data - • ROOM Database - #2 Ins...
Room Database Part 3 - Read Data - • ROOM Database - #3 Rea...
Room Database Part 5 - Delete Data - • ROOM Database - #5 Del...
Timestamps:
0:00 - Introduction
00:32 - Create UpdateFragment
1:12 - Organize Project Structure
2:23 - Design fragment_update Layout
3:16 - Add UpdateFragment to Nav graph
3:35 - Add SafeArgs
4:51 - Implement onClickListener in ListAdapter
8:23 - Update Item in Database
Kotlinx.Synthetic has been deprecated so you should migrate to View Binding instead. 👍👌
If you want to learn more about it then watch this video: ruclips.net/video/MXZz438aCDM/видео.html
One does not simply convert. This was disappointing in your series. It was just too much work to convert your examples. I moved on to other options of instruction.
Very good series, thanks for the time and effort you put into it!
A really good series covering great practice and concepts :)
Thank you so much for these series, very insightful. had to make some minor changes but the overall concept is spot on.
Glad to help 🙏
Stevdza-San,
thank you for your videos, I found a lot of useful knowledge for myself.
Perfect Room lessons !!! Thank you !
your series are one of the best series about android development
Thanks buddy!
@@StevdzaSan do u have any playlist for a complete project with mvvm, retrofit, roomdb, liveData, dagger2/hilt and coroutines
Thanks for the tutorial, it's great
quick question. How would I do this with two fragments? I would like to use one layout for creating and updating the item. So I have one list fragment and one detail fragment.
wow great tutorial man
updating records is like magic, you even don't need to specify user ID to target row data in the database
thank you very much this is a good learning video
Спасибо большое за отличный курс всё получилось !!!!
Fantastic tutorial series! It helped me so much with my app. Well done @Stevdza-San
Glad to hear that!
you are great , thanks
Cool! thanks
Hi! Great tutorial! I just wanted to ask one thing. I'm using switches in my app, and when I come to the update screen, I don't know how to get them to be checked if they were chosen during adding the item. Could you tell me what to do please? What to put instead of setText? I tried using setChecked, but that just gave me the opposite effect.
Hi, great vid. I am having some trouble with updating by passing the whole list, is there something special I need to do? I'm not getting any error, I know the function is being called, but nothing happens.
Hello sir, I have implemented exactly the way you taught. Now I want to add a searchview for this recyclerview with Room data. Do you have any idea how can i do it?
I have used splash screen in my app, so now directly my update fragment is opening instead of list of users as soon as the splash screen ends. How to rectify this error. Thanking you.
When i run the code at 6:33 . When i click on the recyclerView in my app, it crashes and says the constraintLayout does not have a navController set.
I have one question. Is it really impossible to connect to database from all fragments? Why can't we pass just id and then find it from fragment in the database?
Thanks for the great series!
I'm wondering though, how are you able to reference XML views without using findViewById()?
Stevdza-San tell me, should I mark functions in interface UserDao by suspend ?
if you use && in inputcheck method it works not properly
After refactoring the models and such it gives back: Unresolved reference User. even if I revert the changes it gives this error
thank you
Hi bro..
How use of insert or update method base id
thx
This old man, he played three, he played knick-knack on my knee...
👍👍👍
Hi! I have a question and i don't find in anyway, how i can look an user with the lastname for example. I only know how look for Id or index with "it[ ]", but i don't know how look by lastname, or Age, etc
I put My @query correctly but i don't know how bind with the view model and after with the activity
Hello, I got an error at 10:26 saying :
Type mismatch.
Required: Int
Found: String
I think it is related to age. How may I solve this? Thank you.
Oh my bad. I had to use :
val age = Integer.parseInt(binding.updateAgeEt.text.toString())
instead of :
val age = binding.updateAgeEt.text.toString() //
@Parcelize cant be found to put on user class??? need help ? whats the problem actually
plugins {
id("kotlin-parcelize")
}
Idk why, but navArgs doesn't see "UpdateFragmentArgs" what's wrong?
I've added all nav-args and etc. Maybe something is missing?
Enable safe args plugin and add safe args classpath
Hello, my android studio did not report an error, but the data cannot be updated. How to solve this?Thx
same is happing with me also
Hey thanks for this great tutorial
May I ask, must I have add and update as two different fragments ?? What if I send the data from the database to add fragments views on recycler view row item click ? Can this work?
Sure
Also make a short tutorial on working with multiple entities in room database
@@StevdzaSan yes please! id also like to see room database with multiple entities.
Hi Daniel, I'm working on something similar now and want to re-use the same fragment. My question is, how do you change the button and the function behind it to "update" once you navigate there?
@@mikec4220 Use Enum class to represent state whether it's a new item or editing an existing item then change your buttons text accordingly
How do you do it so fastly? And how do you remember the code, snippets, and everything? I can't even remember small codes and you are typing like a God.
He probably typed it many times until his fingers knew what to do
Your series is too good but I'm facing a problem. On clicking on the Add button as addfragment replaces with listfragment but it go back to the addfragment when i press the android back button then move on the listfragment and on the 3rd time it close the app. Can you help me?
You need to debug your app to get to the root of your problem.
Is there a more up-to-date way to do this? I'm studying android studio and some things are not the same in this version I'm in now.
Are you also getting failure with ListFragmentDirections?
@@bartson4425 have you fixed it yet?
Hey, i can't solve ListFragmentDirection, I've checked already all things (
Check for safe args plugin and classpath in your gradle build files. Add them and rebuild the project.
Solved too ) I maked first in build.gradle (Project..)next:
def nav_version = "2.3.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
than: in build.gradle(App..)
apply plugin: 'androidx.navigation.safeargs.kotlin'
@@StevdzaSan Great thanks
@@mercury1352 Ii add this but just appear the args
@@mercury1352 thanks
Tortured to look for answers nowhere. How to find ListFragmentDirections Tell me please ???
That's an auto generated class by safe args plugin.
@@StevdzaSan and here I did not understand Sorry! , but I am a beginner programmer and I can not understand what you said. Can you tell me something that would be clear to me ???
@@StevdzaSan This has happened to me too. I am happy to guide
unresolved reference: listfragmentdirections, I tried rebuilding project several times. Also tried to clean the project and build. Still cannot solve this.
Solved
How did you solve it?
@@user-jg4pk6bq2g My Fragment names were different. So directions file name is different.
In my case i had to add
apply plugin: "androidx.navigation.safeargs.kotlin"
,
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"
@@user-jg4pk6bq2g Oh OK
Someone can't not call ListFragmentDirection just add :
id 'androidx.navigation.safeargs.kotlin' version '2.4.1' apply false ( in build.gradle Project)
id 'androidx.navigation.safeargs.kotlin' ( in build.gradle Module )
Thanks it works!
and still you can't access ListFragmentDirection so
delete that argument and recreate it after adding these dependency to gradle
I love u bruh
Thank you so much, thanks to you I saved a lot of precious time!
5:52 -> lets go to Build.Gradle Project and insert: buildscript {
repositories {
google()
}
dependencies {
def nav_version = "2.3.4"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
id 'androidx.navigation.safeargs.kotlin' version '2.4.1' apply false
}