ROOM Database - #5 Delete Data | Android Studio Tutorial

Поделиться
HTML-код
  • Опубликовано: 31 июл 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 deleting single and multiple items from database table. 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 5): drive.google.com/file/d/1gScJ...
    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 4 - Update Data - • ROOM Database - #4 Upd...
    Timestamps:
    0:00 - Introduction
    0:35 - Create Menu Resource File
    1:33 - Handle Click Event on Menu item
    2:10 - Delete Single User
    6:04 - Delete Everything from table

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

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

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

    Hello, everybody! onCreateMenu function was deprecated, so, use onMenuProvider istead!
    Good luck to you!

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

    Man, I'm new in Android and this tutorial series was exactly what I needed to get my first app going. Tbh, at the time where you were coding, I watched the videos at 0.75, but that's me not being proficient enough to follow along. Huge thanks! I'll definitely check other videos too.

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

    Thank you so much!! Your lessons are the most understandable and useful of all that I have met. I am very glad that I found your channel. You are breathtaking ✨

  • @Ali-yd6fl
    @Ali-yd6fl 2 года назад

    Thanks Man, Finally a series of properly explained concepts

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

    Seriously, great series, I learned a lot. Thanks again!

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

      i need to repractice but yeah its amazing series

  • @Android-sb8uo
    @Android-sb8uo 4 года назад +3

    Amazing tutorial! This is what exactly I'm looking for :) Thank you!

  • @100_gauravmishra6
    @100_gauravmishra6 3 года назад

    Thanks a lot to you for such a good tutorial . This let me understood almost everything about the room database .

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

    Amazing tutorial series!!! Thank you!

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

    Really really the best tutorial. Thank you!!!

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

    That was a great tutorial, thank you very much!

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

    Great tutorial, thank you!

  • @mosayyeb.ebrahimi
    @mosayyeb.ebrahimi 4 года назад

    Best tutorial. Thank you

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

    Interesting how with each video there are less and less views - anyway, thanks for the great tutorial and this elegant (and clean) showcase of room Database - saved my life for college course

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

    Best tutorial, thank you!))

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

    Thanks for your video! I Luckily saw this and get started Room easily. It's all thanks to you.

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

    Bro, u very help me in android, ty so much!!

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

    Thank you it was very usefull!!

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

    Great Great, this is what I wanted

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

    Great Tutorial thank yoiu

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

    Thanks so much... Great !

  • @artianrika8329
    @artianrika8329 10 месяцев назад

    Thank you very much for this quality course😀😀

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

    goog job, thanks for the videos

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

    its amazing series

  • @ristelalkov8836
    @ristelalkov8836 5 месяцев назад

    helped a lot!

  •  3 года назад

    nice tutorial

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

    great tutorial

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

    thank you very mush!!!!! you safe my life!

  • @Waleed_Al-Haidary
    @Waleed_Al-Haidary 4 года назад +1

    Great touterial.

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

    Your serie is so great and fantastic. Your work is Amazing. How to read data from two tables different?

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

    Thanks for this playlist I've learnt a lot from this

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

    Your videos are simply Amazing 😉 great job..It's possible to teach how to join a fragment for each user, please?

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

    Hey. I love your tutorials and this one helped me a lot. Now i'm working on an prepopulate database but room is allways deleting all entries in one specific table and saying no db file. Can you please create a video about it with create From Asset as well?

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

    Thanks for this amazing series 🥰 A question, I have a table layout where the no of rows and columns will be decided by the user, is it possible to save data if we don't know the no of columns the table is gonna have? Could you direct me to a source? Thanks a lot

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

    @Stevdza-San I modified the ListFragment to include a checkbox to see if I could delete a Single User straight from the ListFragment. I tried to replicate the code in the UpdateListFragment; and created a 2nd args for the ListFragment from navigation. It doesn't show any errors in the IDE, but when ran it doesn't do anything. Is there anyway I could make it so this would happen?

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

    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?

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

    how can I solve DELETE query methods must either return void or int (the number of deleted rows). ???

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

    thanks

  • @user-in8yg7rz2c
    @user-in8yg7rz2c 4 года назад

    How to change text to speech in most languages not some in android studio and the app without internet?

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

    Hi, how could I delete one item on a button-click in the RecyclerViewFragment? I have a button on the row layout and want it to delete the single row, but not after navigating to UpdateFragment. Arguments used in RecyclerViewFragment throw some errors and I can't figure out how to do it. If you could help me it would be awesome! I think it has to do, that the argument is "tied?" to UpdateFragment. How could I use it globally? Would it fix the issue?

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

    after deleting all data. if we enter new data it will continue from last ended id. id
    not deleting

  • @divyanshverma2424
    @divyanshverma2424 2 года назад +2

    @Stevdza-San When we add new User after deleteing all the list-items, ID should start from 0 but it is not happening. ID is getting started from next number.

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

      For what purpose do you need that? You can add id to each item from the table by yourself and let the database index itself. 🙃

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

      @@StevdzaSan That's what I did exactly like you but when we delete some item then id skips that number in the item list.

  • @12300michal
    @12300michal 4 года назад

    Thank you for this tutorial series. Also why didn't you make getallusers work on background thread too?

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

      To show you different ways. Glad you noticed 👍

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

    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.

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

    when mUserViewModel.deleteUser(args.currentUser)
    called from dialog I receive error
    that viewmodel not intialized , problem solved by initializing view model inside dialog .
    any idea why it happens . anyway great tutorial

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

    Nice clear and understandable for a newbie like me. I have created the user table with an extra column named Gender. A fragment with two buttons- btnMale and btnFemale. How to show the specific gender list in another fragment with a recycler view by clicking the respective button?

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

      Thank you fro not replying. I got the solution from codinginfinite.com/android-livedata-transformation-example/

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

    thx, but it is looks so difficult for me, i hope i will understand it

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

    Hello, sir. Could you advise me how can I zero the position of recycler view the right way after deleting all users? I mean when deleting all users one adds a new user and it appears with id that proceeds previous user.

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

      Так можно сделать, но в случае, когда таблица не одна, это может всё сломать. Правильнее было бы сделать отдельные ID для списка, которые не зависят от таблицы. Я полагаю, вы уже справились с этой проблемой, но может кому другому будет интересно)

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

      You can do that but it could break all the stuff when there is more than one table. More correct way is to create separate ordinal number for the list. That way they would not depend on table's ID

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

    What is the problem? Please help me :)
    C:\Users\Adem\Desktop\RoomApp\app\build\tmp\kapt3\stubs\debug\com\example
    oomapp\model\@t: error: Cannot find getter for field.
    private final int id = 0;
    [WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).

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

    Why id doesnt change

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

    function from {_ ,_ ->} ?.... meaning

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

    How can we reset the auto generated id ? After deleting all users , if I add another user it gives id to new user according to the number of users I had before deleting .

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

      make another @QUERY on UserDao and give the value "UPDATE sqlite_sequence SET seq = 0" it should reset the sequence to 0

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

    another way to delete single user is just passing a user id to the query like so
    @Query("DELETE FROM user_table WHERE id = :userId")
    suspend fun deleteUser(userId: Int)
    by passing just only user id
    that syntax of :userId is getting from the paramater on deleteUser function
    Great Tutorial Nonetheless 👍

    • @dibbo-mrinmoysaha406
      @dibbo-mrinmoysaha406 3 года назад +1

      I tried exactly this for another app, but it doesn’t work🤔.
      I get always a return error:
      Must return void or int
      Or the app crashes

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

    hello. i just finished this tutorial twice (once trying your database, then adapting to my project).
    that said, I have an error related to unresolved references.
    e: C:\*\*\AndroidStudioProjects\songApplication\app\build\generated\source
    avigation-args\debug\com\pm\songapplication\fragments\list\ListFragmentDirections.kt: (7, 12): Unresolved reference: example
    this might be a long shot to get answer around here due to the lack of info but does anybody have had this error before?

  • @ChinhNguyen-eg5km
    @ChinhNguyen-eg5km 4 года назад

    wonderful tutorial, but can u help me to know between real and room which one is better?

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

    My app uses ROOM database but i couldn't find the data once i built an APK and ran it on my phone. What am i supposed to do now?

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

      That's because you can only see the data when the phone is rooted, or when you're running the emulator. But don't worry, if you really followed the tutorial correctly, the data is there. You don't really need to see it. It will show up when you wire up the ListFragment. He only showed us the underlying database for learning purposes. If you really want to extract the SQLite database, just run the emulator instead, and then extract it from there.

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

    report bug
    when deleting all users and adds a new user , it appears with id that proceeds previous user. the new user id isn't 1

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

      Column id is auto-generated, so it will never be 1 again. Only after deleting the app from your phone

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

      @@RobertMair80 Thanks