ROOM Database - #1 Create Database Schema | Android Studio Tutorial

  Рет қаралды 260,521

Stevdza-San

4 жыл бұрын

🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
stevdza-san.com
🐱‍👤 Wanna become a member? Join!
kzbin.info/door/YLAirIEMMXtWOECuZAtjqQjoin
📸 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 creating a Database schema for our project. 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 1): drive.google.com/file/d/18CGd3YUiHYezGazA4h0rvMYSaksEnoIA/view?usp=sharing
Room Database Part 2 - Insert Data - kzbin.info/www/bejne/i3Omcoqcr9mHqLM
Room Database Part 3 - Read Data - kzbin.info/www/bejne/aYa2p6Vngd9rnZo
Room Database Part 4 - Update Data - kzbin.info/www/bejne/a6PJc4htatiaq80
Room Database Part 5 - Delete Data - kzbin.info/www/bejne/g3eugKqBrcmbrbc
Dependencies:
// Navigation Component
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
// Room components
implementation "androidx.room:room-runtime:2.2.5"
kapt "androidx.room:room-compiler:2.2.5"
implementation "androidx.room:room-ktx:2.2.5"
androidTestImplementation "androidx.room:room-testing:2.2.5"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5"
Timestamps:
0:00 - Introduction
0:39 - ROOM Advantages
1:09 - ROOM Main Components
2:00 - App Preview
2:38 - Dependencies
3:28 - Create Entity
5:07 - Create Dao
7:02 - Create Database
10:49 - Create Repository
12:10 - Create ViewModel

Пікірлер: 210
@TBrianOnline
@TBrianOnline 4 жыл бұрын
It's great to learn from you. I'm glad you're taking your time and putting a good effort into this. So far you are one of the best I've found.
@Kazner0h
@Kazner0h 8 ай бұрын
I watched SO MANY Room "beginner" videos that didn't bother to explain anything. Your video is the first one where I feel like I'm actually being taught how to use Room rather than being told what to type. Thank you SO much. I'm subscribed.
@josephcobbinah5412
@josephcobbinah5412 3 жыл бұрын
I like how you take your time to explain what the various keywords and syntax means. Thank you so much
@ethiomusic3158
@ethiomusic3158 3 жыл бұрын
I started building my database by your tutorial. I think it is smooth according to your soft instructions. I like the way you teach.
@veshvesh2157
@veshvesh2157 3 жыл бұрын
imo this is the best instructor for kotlin programming. Thank u so much for sharing your knowledge!
@ppersik
@ppersik 2 жыл бұрын
Your content is terrific - everything is clear, short, relevant examples and most importantly nothing superfluous. Recently I found your channel and subscribed because it's hard to find good material. Thank you for your tutorials!
@StevdzaSan
@StevdzaSan 2 жыл бұрын
I'm glad I can help 💜
@Tridez99
@Tridez99 Жыл бұрын
if you liked his content why did u say that it's terrific? wtf
@ppersik
@ppersik Жыл бұрын
@@Tridez99 i didn't mean terrific is horrible. It's also mean amazing
@100_gauravmishra6
@100_gauravmishra6 3 жыл бұрын
Best tutorial ever found to learn about room database. Thanks for your efforts.
@itszechs
@itszechs 3 жыл бұрын
Amazing tutorial!! Straight to the point cleared my all my doubts
@prasannadeshpande4435
@prasannadeshpande4435 3 жыл бұрын
Thank you for this tutorial. This clarified few things about MVVM architecture too.
@kevin_joan_re9582
@kevin_joan_re9582 3 жыл бұрын
unbelievably good content mate !!! You explain things so efficiently.
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Thank you buddy, I'm glad to help!
@SlimeAlone
@SlimeAlone 3 жыл бұрын
Man you're the best , Keep goin' !
@manishpingale6558
@manishpingale6558 3 жыл бұрын
Loved new video format man Dont CHANGE IT IT LOOKS GREAT
@HotshotArafath
@HotshotArafath 3 жыл бұрын
You are a gem to kotlin community keep up the good work!!!
@ehtishamhassan8146
@ehtishamhassan8146 4 жыл бұрын
Thank you. Really helpful.👌 Waiting for next video in the series.
@luizfellipeabrantes2933
@luizfellipeabrantes2933 2 ай бұрын
any update on the dependencies? they look different now
@reymondlogatoc2492
@reymondlogatoc2492 2 жыл бұрын
Thank you for this tutorial series. Very helpful!
@angelmhg
@angelmhg 3 жыл бұрын
the best way to understand roomdatabase, thanks and keep go on
@ivankisevskyi5429
@ivankisevskyi5429 3 жыл бұрын
with love from Ukraine, great job, thank you, thanks to you, I finally understood how to work with Room
@harshid4661
@harshid4661 3 жыл бұрын
the best instructor on whole youtube
@2-dwep371
@2-dwep371 3 жыл бұрын
very good video, it helped me a lot. greetings from Mexico....... you already have one more subscriber!
@iqbalrivaldi2856
@iqbalrivaldi2856 Жыл бұрын
I am very happy get very much knowledge about room database in this video. Thanks bro for the tutorial
@canastrao
@canastrao 3 жыл бұрын
Your tutorial is really good. Thanks for share with us.
@alinemansur3824
@alinemansur3824 8 ай бұрын
Teacher, perfect class! I would like a professional opinion from you on the database. For a large app (Airbnb or Uber), using Room for local persistence may be better suited than pure SQLite, right? I ask this because I have no problems writing code using the SQL language. Thank you for your tutorials!
@nazudis
@nazudis 3 жыл бұрын
wtf dude, i love the way u speak!! thanks btw
@m.elnwishy
@m.elnwishy Жыл бұрын
your tutorial is great it's really help me to understand room lib but may you explain why you used coroutines when you insert data only ?
@subhadeepchowdhury5244
@subhadeepchowdhury5244 Жыл бұрын
Great video. I respect the effort.
@theanlaython3470
@theanlaython3470 4 жыл бұрын
val instance = Room.databaseBuilder( context.applicationContext, userDatabase::class.java, "user name" ).build() i got error this part it said Type parameter bound for T in fun databaseBuilder ( context: Context, klass: Class, name: String ) : RoomDatabase.Builder is not satisfied: inferred type userDatabase! is not a subtype of RoomDatabase!
@sahilmahajan9846
@sahilmahajan9846 2 жыл бұрын
Why did you not check whether the INSTANCE field initialized on line 15 is null or not in the synchronized code block in UserDatabase class at 10:00?
@mihirshirgaonkar7832
@mihirshirgaonkar7832 2 жыл бұрын
great very simplified tutorial
@RASTstudio
@RASTstudio 2 жыл бұрын
Thank you too Bro Keep Going! ✊✊✊
@jamperspective6777
@jamperspective6777 2 жыл бұрын
Thanks for this sir. Very useful
@vuanhduong7034
@vuanhduong7034 3 жыл бұрын
fucking best teacher that ever found on KZbin.
@dhakshnamoorthy8673
@dhakshnamoorthy8673 3 жыл бұрын
Hey there I'm creating a chat app and I'm storing the chat messages of each person when I click on them but once I have created a room db it is storing the chat messages of all of them . the thing I need is whenever I click one of my friends chat button a specific room db for them has to open which contains only the chat messages of them and mine. Pls help me to solve this.
@maximcompeers2477
@maximcompeers2477 3 жыл бұрын
Hey man, I really enjoy your video's. Short and concise. But I have a question about reading data from the database. What if I want to read one row and pass the ID into the function. Do I still have to use a coroutine? If yes, how do I return it in the viewmodel method? Or is it OK to not use coroutines when only reading data from the database? Thank you
@jorgeleonardogamarraospino9896
@jorgeleonardogamarraospino9896 3 жыл бұрын
Why is it necessary to initialize the database with the init code block every time UserViewmodel is called?
@suntvhits
@suntvhits Жыл бұрын
very nice explanation sir...Very usefull video.
@hugovera1540
@hugovera1540 Жыл бұрын
Could not find method kapt() for arguments ?
@pillowtalks90
@pillowtalks90 3 жыл бұрын
Why did you return tempInstance at 9:35 , and not INSTANCE? Same question for return instance, below that Because of @Volatile or you just like it that way?
@cheveux9718
@cheveux9718 9 ай бұрын
thankyou !! Really merci
@brandondelacruz934
@brandondelacruz934 3 жыл бұрын
Do you have a tutorial that connects an app with a relational database like mysql?
@annguyenhoang3589
@annguyenhoang3589 4 жыл бұрын
I hope that you will make a tutorial that using mvvm architecture
@bhavsarvrajendra341
@bhavsarvrajendra341 3 жыл бұрын
Loved the video, very simple yet detailed. since you have mentioned Clean Architecture , is there any proper tutorial available ?
@StevdzaSan
@StevdzaSan 3 жыл бұрын
You have my courses on Udemy and Skillshare.
@prasannadeshpande4435
@prasannadeshpande4435 Жыл бұрын
Do I have to create tempInstance variable within getInstance function? what happens if I directly use INSTANCE?
@rondamon4408
@rondamon4408 3 жыл бұрын
Excellent video!
@pushpendratripathi46
@pushpendratripathi46 4 жыл бұрын
Really nice explanation of information. I am waiting for next videos on this series. Thanks for these cool videos.
@jank8456
@jank8456 Жыл бұрын
but in the UserDatabase, if two or more threads invoke getDatabase at the same time, and then they check that tempInstance is null, they all will run synchronized block, in some order, one by one, creating many database instances? Or not?
@Waleed_Al-Haidary
@Waleed_Al-Haidary 4 жыл бұрын
Can you please add a touterial on how sync the database with database on ☁️
@randy4443
@randy4443 4 жыл бұрын
Why do we need compile options since we are working with kotlin and not java?
@kwesiamartey
@kwesiamartey 4 жыл бұрын
Sir i cant wait for the rest of the videos drop it now thanks
@DeepSingh-wk5ts
@DeepSingh-wk5ts 4 жыл бұрын
Thank you , please make videos on mirrorfly & sinch dependcy
@pravinpund7523
@pravinpund7523 3 жыл бұрын
Dear sir, Greetings of the day! I want to create an app which can extract data from excel, csv, xlsx formats and save into android sqlite database and then plot it in Mpandroid chart. If you could help me , please prepare series on it, in kotlin. Searched on youtube but couldn't find good tutorial Thanks in advance
@SERJUAANT
@SERJUAANT 3 жыл бұрын
what a great tutorial
@sofuxjedup8330
@sofuxjedup8330 2 жыл бұрын
still cant understand why do we creating userDao() func in our DB and returning userDao.. What does it mean to return userDao? Is it object of interface?
@maikolsoro1835
@maikolsoro1835 3 жыл бұрын
Steva-San Hi, would be interesting to use or consume a GraphQL API in android kotlin
@Youraverageprogrammer
@Youraverageprogrammer 2 жыл бұрын
That escaleted quickly! Nevertheless great introduction on ROOM.
@QwertyUiop-rt8ou
@QwertyUiop-rt8ou 3 жыл бұрын
#9:36 shouldn't the lock cover Al the function? You can see the problem if you watch again.
@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?
@VeeraSrivastava
@VeeraSrivastava 3 жыл бұрын
Use Query and display your data
@termdatechannel2685
@termdatechannel2685 2 ай бұрын
Thank you.
@tokosuburselalu8689
@tokosuburselalu8689 2 жыл бұрын
thanks for the video, i have a question. i read some article that said, we dont need to determine room/retrofit run in background, because the library itself will do by themselve. So in this case we don't need set Dispatcher.IO for insert. what's your opinion ?
@StevdzaSan
@StevdzaSan 2 жыл бұрын
I think that you don't actually need to specify IO dispatcher explicitly, because newer version of ROOM database is using it by default. However I'm always specifying it, because it cannot do any harm either way.
@tokosuburselalu8689
@tokosuburselalu8689 2 жыл бұрын
@@StevdzaSan thanks for ur explanation 👍
@mustafaserce6090
@mustafaserce6090 3 жыл бұрын
that's great !
@mfz5166
@mfz5166 3 жыл бұрын
i got an error on Dependencies in line 57 were "kapt "androidx.room:room-compiler:2.3.0""
@marcscherzer
@marcscherzer 3 жыл бұрын
Hello, thanks for the tutorial. I would like to ask in 11:09, why the `database` folder does not exist in data > data > com.example. ?
@marcscherzer
@marcscherzer 3 жыл бұрын
Never mind, somehow I needed to stop and then restart the Android Emulator. Thanks. EDIT: I have no idea if I needed to set exportSchema = true in UserDatabase.kt. However, here are what I did : (1) set exportSchema = true in UserDatabase.kt (2) stop the Android Emulator (3) start the Android Emulator (4) open Device File Manager. Search for data > data > com.example. > database. Finally the database folder was displayed. Please correct me if I am wrong, thank for the amazing tutorial Stevdza-san.
@RahulRawat-rj8ol
@RahulRawat-rj8ol 2 жыл бұрын
hello sir can we store list of images in room data base i am unable to do it......
@ziyadmansy6016
@ziyadmansy6016 4 жыл бұрын
are there any prerequisites for this series?
@alfian3570
@alfian3570 3 жыл бұрын
How if i want to populate all data into sqlite, like dictionary app ?
@mervekaraca5499
@mervekaraca5499 4 ай бұрын
Will we repeat the same processing for a second table?
@dashaxedit
@dashaxedit 3 жыл бұрын
Hey. Thanks. What is ORDER BY id ASC for? In the Dao getalldata function
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Sort and get the list in ascending order.
@87nehal
@87nehal 2 жыл бұрын
Can you please make a video on how to export a database as csv or txt file?🙏
@FreePhoenix888
@FreePhoenix888 2 жыл бұрын
This tutorial is more valuable than google guides
@StevdzaSan
@StevdzaSan 2 жыл бұрын
Thanks 😎
@sunitthakur9913
@sunitthakur9913 2 жыл бұрын
Best
@damonkopsidas
@damonkopsidas 3 жыл бұрын
Is there a tutorial on how to do this in Java?
@androidmillennium9266
@androidmillennium9266 2 жыл бұрын
Thanks a lot
@doobofbattle9472
@doobofbattle9472 3 жыл бұрын
So if we have multiple entities / tables, do we need a Dao, Repository, and ViewModel for each?
@marijocarbajal6968
@marijocarbajal6968 3 жыл бұрын
i think so
@vaibhavjadiya6638
@vaibhavjadiya6638 3 жыл бұрын
Can we make and manage Room Database in Java too.?
@DreamInterpretation01
@DreamInterpretation01 3 жыл бұрын
Hello Stevdza-San, this is excelent example of Room with Kotlin. But, how can we implement SearchView and query our database? Regards
@StevdzaSan
@StevdzaSan 3 жыл бұрын
I will make a new video about it next week, since lots of you have asked me the same. 👍
@binodbasnet1762
@binodbasnet1762 3 жыл бұрын
Why we make UserDao as interface . I know interface but i dont know pratical implementation of interface
3 жыл бұрын
I'm try to code follow your video, but when i click on floatButton it show this error: "java.lang.RuntimeException: Cannot create an instance of class com.tda.android_training_vangthao.viewholder.StudentViewModel" (I use Student instead of User). Please help me
@codemachine19
@codemachine19 2 жыл бұрын
do u can solve this problem ?
2 жыл бұрын
@@codemachine19 It's been a long time so I don't remember if the problem has been solved yet
@hoddiewarrior4505
@hoddiewarrior4505 3 жыл бұрын
i get this when i try to access your google play store link : We're sorry, the requested URL was not found on this server.
@dennisgonzales9521
@dennisgonzales9521 4 жыл бұрын
Awesome
@prantosaha8546
@prantosaha8546 Жыл бұрын
Dear, Can you please tell me why minimumSDK should be 26.
@technics6215
@technics6215 Жыл бұрын
I think your synchronized singleton implementation is wrong. When two threads enter at the same time they both pass null check, and they both will try to build instance. Synchronized block should start before null check, actually it may cover the entire function. Only one thread should be able to discover that there is no instance yet, create it and then leave synchronized block. After this other thread(s) will be allowed to enter, and get instance created by first thread.
@mauriciopriego1700
@mauriciopriego1700 2 жыл бұрын
thank you
@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.
@hoddiewarrior4505
@hoddiewarrior4505 3 жыл бұрын
I don't know i wonder the same thing but this is the only thing that comes to mind maybe practice
@tnnz9920
@tnnz9920 3 жыл бұрын
sir why my code always error and they said value null on entity?
@tytee7794
@tytee7794 Жыл бұрын
Having difficulties, the project files are not complete... can you update the download link
@siphesihlezanwga13
@siphesihlezanwga13 9 ай бұрын
i will follow that Russian mafia voice to anywhere
@chadpaulsen2953
@chadpaulsen2953 2 жыл бұрын
anyone else have issues in the ViewModel? i keep getting an error with AddUser. and it doesn't like LiveData either. it works for him, but not for me.
@cdm1949
@cdm1949 2 жыл бұрын
How would I join two tables and retrieve data?
@muhriddingayratov1791
@muhriddingayratov1791 2 жыл бұрын
well video lesson thanks
@onlinechatter8578
@onlinechatter8578 3 жыл бұрын
Kindly make a video to CRUD the room database using Firebase!!!
@mikelantzelo
@mikelantzelo 3 жыл бұрын
Thank you Thank you Thank you
@the_sharma_amit
@the_sharma_amit 3 жыл бұрын
Please make videos on Dependency injection, Daggar, Daggar 2, Hilt...
@tobias3344
@tobias3344 Жыл бұрын
Can someone help me out and tell me how to write the code at 12:03 in Java? Thanks!
@HalimFurniture
@HalimFurniture Жыл бұрын
GL bro
@manishpingale6558
@manishpingale6558 3 жыл бұрын
do you record code and then add voice??
@randy4443
@randy4443 4 жыл бұрын
I can't open the grade in the drive
@moataz2415
@moataz2415 3 жыл бұрын
is there any room series for java
@atifabbasi7358
@atifabbasi7358 3 жыл бұрын
how to check if user is added successfully.?
@VictorHugoGrabowskiBeltramini
@VictorHugoGrabowskiBeltramini 2 жыл бұрын
this works as well when using Java ?
@bakaiismaiilov4732
@bakaiismaiilov4732 3 жыл бұрын
Hey Stevdza love your tutorials👌 Keep it up! And How do you read documentation within android Studio ? You used ctrl + Q, what is the shortcut for Mac ?
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Yep. Command + Q I guess. 👍
@bakaiismaiilov4732
@bakaiismaiilov4732 3 жыл бұрын
@@StevdzaSan didn't work) i guess i need to set up smth in studio. THANK YOU ANYWAYS
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 70 МЛН
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 33 МЛН
Red❤️+Green💚=
00:38
ISSEI / いっせい
Рет қаралды 73 МЛН
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 43 МЛН
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 70 МЛН