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

Комментарии • 92

  • @StevdzaSan
    @StevdzaSan  2 года назад

    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

    • @runknown7366
      @runknown7366 2 года назад

      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.

  • @Indently
    @Indently 4 года назад +10

    Very good series, thanks for the time and effort you put into it!

  • @iftak01
    @iftak01 2 года назад +1

    A really good series covering great practice and concepts :)

  • @phillvaloyi3803
    @phillvaloyi3803 2 года назад +1

    Thank you so much for these series, very insightful. had to make some minor changes but the overall concept is spot on.

  • @maxs20s
    @maxs20s Год назад

    Stevdza-San,
    thank you for your videos, I found a lot of useful knowledge for myself.

  • @oleg12395
    @oleg12395 2 года назад

    Perfect Room lessons !!! Thank you !

  • @zakwanibrahim7283
    @zakwanibrahim7283 Год назад +2

    your series are one of the best series about android development

    • @StevdzaSan
      @StevdzaSan  Год назад

      Thanks buddy!

    • @zakwanibrahim7283
      @zakwanibrahim7283 Год назад

      @@StevdzaSan do u have any playlist for a complete project with mvvm, retrofit, roomdb, liveData, dagger2/hilt and coroutines

  • @ericgoto2459
    @ericgoto2459 4 года назад

    Thanks for the tutorial, it's great

  • @ismailkassim6325
    @ismailkassim6325 4 года назад

    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.

  • @bisquestudio
    @bisquestudio 3 года назад

    wow great tutorial man

  • @arel027
    @arel027 2 года назад

    updating records is like magic, you even don't need to specify user ID to target row data in the database

  • @user-bj8fl7rf5l
    @user-bj8fl7rf5l Месяц назад

    thank you very much this is a good learning video

  • @brigadir5830
    @brigadir5830 Год назад

    Спасибо большое за отличный курс всё получилось !!!!

  • @michaelk7942
    @michaelk7942 Год назад

    Fantastic tutorial series! It helped me so much with my app. Well done @Stevdza-San

  • @07722796723
    @07722796723 3 года назад

    you are great , thanks

  • @surflaweb
    @surflaweb 2 года назад

    Cool! thanks

  • @klmnxyz2823
    @klmnxyz2823 3 года назад

    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.

  • @osambrojevanisam3575
    @osambrojevanisam3575 3 года назад +1

    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.

  • @karanbobade5266
    @karanbobade5266 3 года назад +1

    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?

  • @somyatomar6292
    @somyatomar6292 3 года назад

    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.

  • @chop5388
    @chop5388 2 года назад +1

    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.

  • @tayjen59
    @tayjen59 3 года назад +1

    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?

  • @charlielidstone
    @charlielidstone 2 года назад

    Thanks for the great series!
    I'm wondering though, how are you able to reference XML views without using findViewById()?

  • @oleg12395
    @oleg12395 2 года назад

    Stevdza-San tell me, should I mark functions in interface UserDao by suspend ?

  • @user-bk5il2fy1h
    @user-bk5il2fy1h 3 года назад

    if you use && in inputcheck method it works not properly

  • @Bazs121
    @Bazs121 Год назад

    After refactoring the models and such it gives back: Unresolved reference User. even if I revert the changes it gives this error

  • @user-bj8fl7rf5l
    @user-bj8fl7rf5l 3 месяца назад

    thank you

  • @sudharsanraja2843
    @sudharsanraja2843 Год назад

    Hi bro..
    How use of insert or update method base id

  • @elpirato5428
    @elpirato5428 3 года назад +1

    thx

  • @altinshima7068
    @altinshima7068 3 года назад

    This old man, he played three, he played knick-knack on my knee...

  • @zafarjontoshtemirov4035
    @zafarjontoshtemirov4035 3 года назад +1

    👍👍👍

  • @TheUmi48
    @TheUmi48 3 года назад

    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

    • @TheUmi48
      @TheUmi48 3 года назад

      I put My @query correctly but i don't know how bind with the view model and after with the activity

  • @marcscherzer
    @marcscherzer 3 года назад +1

    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.

    • @marcscherzer
      @marcscherzer 3 года назад +2

      Oh my bad. I had to use :
      val age = Integer.parseInt(binding.updateAgeEt.text.toString())
      instead of :
      val age = binding.updateAgeEt.text.toString() //

  • @MrNik-zv7dp
    @MrNik-zv7dp 2 года назад +1

    @Parcelize cant be found to put on user class??? need help ? whats the problem actually

  • @damask_
    @damask_ 3 года назад +1

    Idk why, but navArgs doesn't see "UpdateFragmentArgs" what's wrong?
    I've added all nav-args and etc. Maybe something is missing?

    • @StevdzaSan
      @StevdzaSan  3 года назад +1

      Enable safe args plugin and add safe args classpath

  • @adyloxada4211
    @adyloxada4211 3 года назад +1

    Hello, my android studio did not report an error, but the data cannot be updated. How to solve this?Thx

  • @danielwaiguru4359
    @danielwaiguru4359 4 года назад

    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?

    • @StevdzaSan
      @StevdzaSan  4 года назад +1

      Sure

    • @danielwaiguru4359
      @danielwaiguru4359 4 года назад +2

      Also make a short tutorial on working with multiple entities in room database

    • @Dcutz
      @Dcutz 3 года назад

      @@StevdzaSan yes please! id also like to see room database with multiple entities.

    • @mikec4220
      @mikec4220 3 года назад

      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?

    • @danielwaiguru4359
      @danielwaiguru4359 3 года назад

      @@mikec4220 Use Enum class to represent state whether it's a new item or editing an existing item then change your buttons text accordingly

  • @karanbobade5266
    @karanbobade5266 3 года назад +1

    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.

    • @arel027
      @arel027 2 года назад

      He probably typed it many times until his fingers knew what to do

  • @malikabdulrehman7338
    @malikabdulrehman7338 2 года назад

    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?

    • @StevdzaSan
      @StevdzaSan  2 года назад

      You need to debug your app to get to the root of your problem.

  • @dlnnascimento
    @dlnnascimento Год назад

    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.

    • @bartson4425
      @bartson4425 Год назад

      Are you also getting failure with ListFragmentDirections?

    • @truongxuan8322d
      @truongxuan8322d 11 месяцев назад

      @@bartson4425 have you fixed it yet?

  • @mercury1352
    @mercury1352 3 года назад +6

    Hey, i can't solve ListFragmentDirection, I've checked already all things (

    • @StevdzaSan
      @StevdzaSan  3 года назад +3

      Check for safe args plugin and classpath in your gradle build files. Add them and rebuild the project.

    • @mercury1352
      @mercury1352 3 года назад +12

      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'

    • @mercury1352
      @mercury1352 3 года назад

      ​@@StevdzaSan Great thanks

    • @viniciushenriquedeoliveira289
      @viniciushenriquedeoliveira289 3 года назад

      @@mercury1352 Ii add this but just appear the args

    • @user-rh9lg8se6f
      @user-rh9lg8se6f 2 года назад

      @@mercury1352 thanks

  • @user-qb6ct2im7z
    @user-qb6ct2im7z 2 года назад

    Tortured to look for answers nowhere. How to find ListFragmentDirections Tell me please ???

    • @StevdzaSan
      @StevdzaSan  2 года назад +1

      That's an auto generated class by safe args plugin.

    • @user-qb6ct2im7z
      @user-qb6ct2im7z 2 года назад

      @@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 ???

    • @hadi.arzanipour
      @hadi.arzanipour 2 года назад

      @@StevdzaSan This has happened to me too. I am happy to guide

  • @sanjuwamobile9418
    @sanjuwamobile9418 4 года назад +1

    unresolved reference: listfragmentdirections, I tried rebuilding project several times. Also tried to clean the project and build. Still cannot solve this.

    • @sanjuwamobile9418
      @sanjuwamobile9418 4 года назад

      Solved

    • @user-jg4pk6bq2g
      @user-jg4pk6bq2g 3 года назад

      How did you solve it?

    • @sanjuwamobile9418
      @sanjuwamobile9418 3 года назад

      @@user-jg4pk6bq2g My Fragment names were different. So directions file name is different.

    • @user-jg4pk6bq2g
      @user-jg4pk6bq2g 3 года назад +7

      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"

    • @sanjuwamobile9418
      @sanjuwamobile9418 3 года назад

      @@user-jg4pk6bq2g Oh OK

  • @nguyenminhkhoa6436
    @nguyenminhkhoa6436 Год назад +9

    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 )

    • @mrmercer1992
      @mrmercer1992 Год назад

      Thanks it works!
      and still you can't access ListFragmentDirection so
      delete that argument and recreate it after adding these dependency to gradle

    • @parsifal2112
      @parsifal2112 Год назад

      I love u bruh

    • @mquit
      @mquit Год назад

      Thank you so much, thanks to you I saved a lot of precious time!

  • @oleg12395
    @oleg12395 2 года назад +1

    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
    }