Room Database & Type Converters in Android | Singleton Pattern Room Hindi- CheezyCode #11

  Рет қаралды 29,062

Cheezy Code

Cheezy Code

3 жыл бұрын

Learn Type Converters in Android Room Database. Learn how to implement a singleton pattern for Room Database in Kotlin to have a single instance of the database for the whole application. Room Persistence library is like an ORM tool that helps in storing entities directly into the database. SQLite supports limited data types, to support custom data types or other types such as Date or UUID - we need TypeConverters.
Learn how to use companion object with @Volatile and synchronized block in Kotlin. Learn how to use SQLite in Android using Room Jetpack Architecture Components. Learn all this about Android Jetpack Components in Hindi by creating small projects.
These components help in writing clean code and help in following clean architecture in android. Learn all this about Android in Hindi by creating small projects. Everything is explained in Hindi (हिंदी में )
Topics Covered -
1. Singleton Pattern in Kotlin
2. Thread Safe Singleton pattern implementation - Room Database
3. Need of Singleton
4. TypeConverters (@TypeConverter, @TypeConverters) in Android Room
5. Simple Example of Room Database
Kotlin Companion Object Video -
• Kotlin Companion Objec...
ViewModel Concept -
• Android ViewModel Tuto...
ViewModelFactory -
• Android ViewModel Fact...
Beginner series in Android Playlist (Hindi) -
• Android Tutorials Step...
Kotlin Beginners Tutorial Series -
• Kotlin Beginner Tutori...
For more info - visit the below link
www.cheezycode.com
We are social. Follow us at -
Facebook - / cheezycode
Twitter - / cheezycode
Instagram - / cheezycode

Пікірлер: 84
@preetamgupta3532
@preetamgupta3532 3 жыл бұрын
सर आपके बताने का तरीका बहुत अच्छा हैं।🙏 अच्छे से चीजे समझ आती है। Thanku Sir
@CheezyCode
@CheezyCode 3 жыл бұрын
Thank you 🤘
@computerghyan9391
@computerghyan9391 Жыл бұрын
Nice job sir 👍 Your tutorial is very helpful. Love you ❤️❤️ so much ❣️ sir Love from Indore Madhya Pradesh.
@Subratsss
@Subratsss 3 ай бұрын
Very good explanation
@sarkheelmughal6545
@sarkheelmughal6545 3 жыл бұрын
this playlist helps me a lot. kindly cover all other jetpack topics as soon as possible especially MVVM. thanks for such content.
@CheezyCode
@CheezyCode 3 жыл бұрын
Thank you 🤘 and mvvm for sure
@Maheshl43
@Maheshl43 Жыл бұрын
@@CheezyCode waiting
@Punarjagran
@Punarjagran 3 жыл бұрын
BLESSED TO FIND YOU.. I SPREAD THESE VIDEOS & THIS BRAND / CHANNEL A LOTTT
@CheezyCode
@CheezyCode 3 жыл бұрын
Thank you 🤘...aapka din shubh ho 😁
@Punarjagran
@Punarjagran 3 жыл бұрын
@@CheezyCode aapka bhi 🙏✨
@ShivamPatel-vp5pb
@ShivamPatel-vp5pb Жыл бұрын
Amazing Explanation Sir ❤🫡
@vidhidixit5003
@vidhidixit5003 2 жыл бұрын
Always Well Explained !! Thanks
@CheezyCode
@CheezyCode 2 жыл бұрын
Thanks Vidhi
@kishorramani007
@kishorramani007 3 жыл бұрын
Thanks 🙌 Ending music and song is nice 🙂
@CheezyCode
@CheezyCode 3 жыл бұрын
Thanks
@moeed1584
@moeed1584 3 жыл бұрын
very much helpful contents Thanks sir
@CheezyCode
@CheezyCode 3 жыл бұрын
Thanks Abdul
@Maheshl43
@Maheshl43 Жыл бұрын
Love you don't stop
@dogsgallery2199
@dogsgallery2199 3 жыл бұрын
Thnx for everything cheezy code
@CheezyCode
@CheezyCode 3 жыл бұрын
Thank you 🤘
@gajukollur7591
@gajukollur7591 9 ай бұрын
Sir , why companion object... we can directly achieve singleton using just object
@saurabhpandey9077
@saurabhpandey9077 3 жыл бұрын
Bht se resources available hai android development ko le k in the form of videos, articles post etc. But the way you explain is just amazing ek bar me hi smjh aa jata hai and i am sure all 40.5K subscribers will be agree with me You are awesome Thank you so much. and my humble request is that can you please videos on Dagger hilt
@CheezyCode
@CheezyCode 3 жыл бұрын
Thanks Saurabh....Dependency Injection and Coroutines will be next....stay tuned
@BCS_AAMIRASHRAF
@BCS_AAMIRASHRAF Жыл бұрын
thanku sir just amazing❤❤❤
@CheezyCode
@CheezyCode Жыл бұрын
@Sweetcracks
@Sweetcracks 3 жыл бұрын
Bro make a quick series on scope storage trending topic cz devs r still confused about this topic..
@sat_talk
@sat_talk 2 жыл бұрын
Great video.. keep it up. After finishing this series pl. make a series on Firebase Push Notification ( especially when app is no longer in background). I found many videos on that but they only showed either foreground or background scenarios.. no video found based on how to get Notification when app is no longer running in background which is realtime case ..
@CheezyCode
@CheezyCode 2 жыл бұрын
Noted
@gamenation9222
@gamenation9222 3 жыл бұрын
Thank you #CheezyCode
@CheezyCode
@CheezyCode 3 жыл бұрын
Thank you 🤘
@rabindratiduar728
@rabindratiduar728 10 ай бұрын
❤❤❤❤
@jineshsharma2780
@jineshsharma2780 Ай бұрын
Sir how to create the type convertor for Files and images
@sunilkumar-zl6eo
@sunilkumar-zl6eo 3 жыл бұрын
Great Teaching sir.....if possbile please provide the content "like website" for new video so that we can prepare for interview.........please sir...
@CheezyCode
@CheezyCode 3 жыл бұрын
bilkul bro koshish karte hai...
@pankajgupta8211
@pankajgupta8211 2 жыл бұрын
Sir, this code this work only one time when i again run the program the app is crashing please help i cannot find out the problem i done all the things correctly .
@arjundixit5913
@arjundixit5913 3 жыл бұрын
Nice explanation. Just one confusion, as mentioned by you in kotlin tutorial , object is used to create a synchronised singleton instance, then why are we again using the java way to create singleton inside the companion object ? I mean is it not defeating the whole purpose of it?
@CheezyCode
@CheezyCode 3 жыл бұрын
It all depends how you access the object. If you access the object in the application class, you can define simple object declaration that will work. But we are accessing it with in activity - it is better to have thread safe singleton.
@arjundixit5913
@arjundixit5913 3 жыл бұрын
@@CheezyCode Sorry bhai but samjh nhi aaya..firstly ki object b toh thread safe hota h na? secondly activiy me aisi kya problem h jis wjah se simple object decalaration will not work...but will work in application? pls agar aap thoda detail m smjha sko because i want to clear my concepts
@Sikarwar0020
@Sikarwar0020 3 жыл бұрын
Sir Coroutines ko bhi details me explain kr dena.. I am really enjoying this playlist.
@CheezyCode
@CheezyCode 3 жыл бұрын
Sure bro...Coroutines pe dil se content ban rha hai....poori koshish
@Sikarwar0020
@Sikarwar0020 3 жыл бұрын
@@CheezyCode thanks a lot 😇
@rashidullah1412
@rashidullah1412 Жыл бұрын
sir why suspend is not working when i removed suspend work properly but is still there is not there in background thread how shou;d i do sir
@dogsgallery2199
@dogsgallery2199 3 жыл бұрын
React native oe video banaiye
@mohammadtaqi4051
@mohammadtaqi4051 2 жыл бұрын
Database me agar 2 column me long value ho to kya dono long value to time me convert karega? Agr nahi to fir usko kese pata chalega k konsi long column ke liye ye converter use krna hai?
@CheezyCode
@CheezyCode 2 жыл бұрын
Datatypes same hai toh converter chalega...aur ye try karo - clarity jabhi aayegi...question toh answer hojayege
@anujvaish2513
@anujvaish2513 2 жыл бұрын
Bhai gana bahut acha hai
@CheezyCode
@CheezyCode 2 жыл бұрын
50k pe release karna h
@deepeshkumar1704
@deepeshkumar1704 Жыл бұрын
If we have multi type converter, then how compiler know, which type converter they have to use??
@deepeshkumar1704
@deepeshkumar1704 Жыл бұрын
cheked your replies on previous comments, found solution, Thanks❤
@deepeshkumar1704
@deepeshkumar1704 Жыл бұрын
but if you have another way to explain now, pls Thanks❤
@ChocoByte
@ChocoByte Жыл бұрын
Here, you made a convertor for date, but how to make convertor for any different types or any custom class. I need a convertor for type FILE
@CheezyCode
@CheezyCode Жыл бұрын
Convert that to Binary...but I would suggest not to store that in DB...store it as a file only - just store the file name inside sqlite
@ChocoByte
@ChocoByte Жыл бұрын
@@CheezyCode" store it as file only" ? Data type "File" is not available in DB....then how...?
@H1MANSHU
@H1MANSHU Жыл бұрын
7:34 ; at this point , I think stupids like me will definitely select @TypeConverters in place of @TypeConverter as it was suggested first , which is going to throw a compile time error !
@GAGANDEEP901
@GAGANDEEP901 2 жыл бұрын
can anyone answer, this is SQLlite right?
@CheezyCode
@CheezyCode 2 жыл бұрын
Yes behind the scenes it is SQLite
@mubaraknative
@mubaraknative Жыл бұрын
Bro in this 6:41 typeconvertor we convert Data to Long for inserting for Fetching Long to Data is used when i will use in my real application the data will show as like this Wed jul 29 19:24:54 GMT + 05:30 2023 simply i want to format the data how to do that bro how to format like DD/MM/YY only
@CheezyCode
@CheezyCode Жыл бұрын
Just google it
@CheezyCode
@CheezyCode Жыл бұрын
stackoverflow.com/a/61410177
@CheezyCode
@CheezyCode Жыл бұрын
stackoverflow.com/a/11773496
@historicalheros9684
@historicalheros9684 3 жыл бұрын
jab me database me data insert karta hu to app crash ho jata he , muje pata nahi kyu. aap help kar sakte ho
@CheezyCode
@CheezyCode 3 жыл бұрын
Check the logcat for the error
@rishabhgupta655
@rishabhgupta655 Жыл бұрын
gana ka kya naam h mil nahi raha h
@CheezyCode
@CheezyCode Жыл бұрын
Gaana karege release...inhouse h
@dumbguy1073
@dumbguy1073 Жыл бұрын
How will that automatically convert from date to long and long to date?????
@BhardwajHackology
@BhardwajHackology Жыл бұрын
same question, how does it know when to Convert what to convert, we didnt define it here
@CheezyCode
@CheezyCode Жыл бұрын
Primitive types don't need conversion Whenever it encounters types other than primitives - it looks for type converters. If type converters are present, it uses these functions to convert values, otherwise will throw an error.
@BhardwajHackology
@BhardwajHackology Жыл бұрын
@@CheezyCode means It will look for a function that takes data type that needs to be converted, if it is present then it will use that function right ?
@CheezyCode
@CheezyCode Жыл бұрын
Yes...check type converters documentation
@BhardwajHackology
@BhardwajHackology Жыл бұрын
@@CheezyCode Sure, I’ll check, Thanks for your time 🫶
@raokarampal
@raokarampal 3 жыл бұрын
Bhai vo converter wale fun jo banaye hai vo call kaha se kiye hai date ko change karne ke liye? Smaj nahi aaya yaar? 🤔 7:58 ke baad samaj nahi aaya
@CheezyCode
@CheezyCode 3 жыл бұрын
Room apne aap call karta hai...contactdatabase pe typeconverters ki annotation add kari h
@raokarampal
@raokarampal 3 жыл бұрын
@@CheezyCode uske kaise pata kon sa call karna hai matlab agar m usme ek or fun rakhu FromlongtoString(value :Long) : string{ return str(value) } To kya hoga?
@CheezyCode
@CheezyCode 3 жыл бұрын
Bro data type check hota hai.... function jisme date type ka input ho, wo use hoga... Fir jab wapsi long jisme input hoga wo use hoga..room check karta hai data type dekh ke
@CheezyCode
@CheezyCode 3 жыл бұрын
Entity ke andar jo field h uska type bhi toh dekhega...string banane se date type kaise milega
@CheezyCode
@CheezyCode 3 жыл бұрын
Acha aise samajh skte ho - Room ne dekha entity ke andar date hai...usne kaha date store nahi kar skta - convertors pe pahocha usne dekha - koi aisa function jo input mei date le rha ho...usse mila ek function jo date ko long mei convert kar rha tha.... Ab access kar rha hu database se - value mili long usne kaha long ke liye koi aisa method hai jo date mei convert kar rha ho - usse mil gya - usko use kar liya usne
@SachaHindu88
@SachaHindu88 2 жыл бұрын
Little Correction fun getInstance(context: Context): ContactDatabase { if (INSTANCE == null) { synchronized(this) { if (INSTANCE == null) { INSTANCE = Room.databaseBuilder( context.applicationContext, ContactDatabase::class.java, "ContactDB" ).build() } } } return INSTANCE!! }
@deepsheth1086
@deepsheth1086 Жыл бұрын
why another if in inside ?
Room Database & Migrations in Android Hindi - CheezyCode #12
9:00
Opensource, Uncensored, Unbothered. - Flux.1 Image Gen
18:59
MattVidPro AI
Рет қаралды 2,6 М.
哈莉奎因以为小丑不爱她了#joker #cosplay #Harriet Quinn
00:22
佐助与鸣人
Рет қаралды 8 МЛН
Database and Room TypeConverter - MVVM News App
9:43
Philipp Lackner
Рет қаралды 35 М.
The Full Guide About the DateTime API in Kotlin
18:28
Philipp Lackner
Рет қаралды 17 М.
#2 How to use Hilt with Room Database ( Complete guide  )
1:04:03
Android Geek
Рет қаралды 3,7 М.
MongoDB Schema Design Best Practices
9:58
MongoDB
Рет қаралды 152 М.