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
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
Hello, everybody! onCreateMenu function was deprecated, so, use onMenuProvider istead!
Good luck to you!
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.
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 ✨
Thanks Man, Finally a series of properly explained concepts
Seriously, great series, I learned a lot. Thanks again!
i need to repractice but yeah its amazing series
Amazing tutorial! This is what exactly I'm looking for :) Thank you!
Thanks a lot to you for such a good tutorial . This let me understood almost everything about the room database .
Amazing tutorial series!!! Thank you!
Really really the best tutorial. Thank you!!!
That was a great tutorial, thank you very much!
Great tutorial, thank you!
Best tutorial. Thank you
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
Best tutorial, thank you!))
Thanks for your video! I Luckily saw this and get started Room easily. It's all thanks to you.
Glad I can help!
Bro, u very help me in android, ty so much!!
Thank you it was very usefull!!
Great Great, this is what I wanted
Great Tutorial thank yoiu
Thanks so much... Great !
Thank you very much for this quality course😀😀
goog job, thanks for the videos
its amazing series
helped a lot!
nice tutorial
great tutorial
thank you very mush!!!!! you safe my life!
Great touterial.
Your serie is so great and fantastic. Your work is Amazing. How to read data from two tables different?
Thanks for this playlist I've learnt a lot from this
Glad to help! 👊
Your videos are simply Amazing 😉 great job..It's possible to teach how to join a fragment for each user, please?
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?
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
@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?
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?
how can I solve DELETE query methods must either return void or int (the number of deleted rows). ???
thanks
How to change text to speech in most languages not some in android studio and the app without internet?
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?
after deleting all data. if we enter new data it will continue from last ended id. id
not deleting
@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.
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. 🙃
@@StevdzaSan That's what I did exactly like you but when we delete some item then id skips that number in the item list.
Thank you for this tutorial series. Also why didn't you make getallusers work on background thread too?
To show you different ways. Glad you noticed 👍
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.
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
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?
Thank you fro not replying. I got the solution from codinginfinite.com/android-livedata-transformation-example/
thx, but it is looks so difficult for me, i hope i will understand it
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.
Так можно сделать, но в случае, когда таблица не одна, это может всё сломать. Правильнее было бы сделать отдельные ID для списка, которые не зависят от таблицы. Я полагаю, вы уже справились с этой проблемой, но может кому другому будет интересно)
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
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).
Why id doesnt change
function from {_ ,_ ->} ?.... meaning
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 .
make another @QUERY on UserDao and give the value "UPDATE sqlite_sequence SET seq = 0" it should reset the sequence to 0
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 👍
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
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?
wonderful tutorial, but can u help me to know between real and room which one is better?
, I think Room
(If you don‘t need very Advanced stuff)
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?
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.
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
Column id is auto-generated, so it will never be 1 again. Only after deleting the app from your phone
@@RobertMair80 Thanks