Android SQLite Database Tutorial 📱 Complete 1-HOUR SQLite Android Tutorial | Kotlin & Android Studio

  Рет қаралды 56,200

tutorialsEU

tutorialsEU

4 жыл бұрын

🚀 Android & Kotlin Masterclass - Become a serious Android app developer with our best-selling masterclass: bit.ly/3PaKdhS
In this video, you will learn everything about the Android SQLite Database with a great examples.
Using this Android SQLite database tutorial I will show you how to perform all the crud operations like Create, Insert, Update, and Delete.
In-depth Android SQLite Database Tutorial
SQLite database is an opensource, lightweight, no network access, and standalone SQL database that stores data to a text file on a device. SQLite database supports all the relational database features. SQLite is a build-in database implementation that comes with Android. You don’t need to establish any connections like JDBC, ODBC, or any other external connection for it, like what you will need to do in java applications.
In Android, whenever an application needs to store a large amount of data the SQLite is the most preferred. It is better than any other repository systems like SharedPreferences or saving data in files. For many applications in Android, SQLite is the backbone of the app, whether it’s used directly or via some third-party wrapper.
SQLite Database Package
To use the SQLite database in the Android application, the main package will be android.database.sqlite.
Three main components are used to handle SQLite operations in Android:
SQLiteOpenHelper Class
The SQLiteOpenHelper class is used to determine the name and version of the database used in this class. It is responsible for opening the database if it exists, creating if it does not exists and upgrading if required.
There are the onCreate() and onUpgrade() methods.
onCreate() invoked if the database doesn’t exist, meaning the very first time dealing with the SQLite database. Moreover, the onUpgrade() method is used to update the database schema to the most recent or, let’s say, the existing without losing the data:
SQLiteDatabase in Android
The base class of the SQLite database class is SQLiteDatabase.
Android has its implementation to perform CRUD (Create, Read, Update, Delete) operations.
The SQLiteDatabase have methods such as insert(), update(), delete() and also execSQL() which are used for the execution of the database.
Cursor
The query function will return the cursor object, which results from a query. One record is equal to the row of the query results.
In Android, the cursor can perform buffer query results efficiently as it does not need to load the data into the memory.
The most commonly used methods of the cursor are getCount(), moveToFirst(), moveToNext(). The getCount() used to get the number of records from the query results. The moveToFirst() used to move to the first record of the line. And the moveToNext() used to move to the next line.
If you need additional details from our SQLite android tutorial, you can have a look at the official documentation of Android SQLite Database.
For using the methods insert() and update(), you need to define the object ContentValues in terms of KEY and VALUE to the table. The key represents the identity column of the table. And the value represents the record of the table of the column.
The query can be built in the SQLite database with the methods such as rawQuery() and query() using the SQLiteQueryBuilder class. The rawQuery() method accepts an SQL statement as input.
The query() method has a structured interface in terms of parameters to specify the SQL query. The SQLiteQueryBuilder class allows you to create SQL queries.
Example of Query()
return database.query(EmployeeTable,new String[]{key_1,key_2,...},null,null,null,null,null);
1
return database.query(EmployeeTable,new String[]{key_1,key_2,...},null,null,null,null,null);
Example of rawQuery()
Cursor cursor = getReadableDatabase();
rawQuery("select * from EmployeeTable);
1
2
Cursor cursor = getReadableDatabase();
rawQuery("select * from EmployeeTable);
#SQLite #androidSQLite #androidSQLiteTutorial
🔥🔥 Get my Android Masterclass for 90% OFF! bit.ly/3l7RzkQ
Check out the article including the code:
tutorials.eu/android-sqlite-d...
tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x

Пікірлер: 74
@tutorialsEU
@tutorialsEU 3 жыл бұрын
🚀 Android & Kotlin Masterclass - Become a serious Android app developer with our best-selling masterclass: bit.ly/3PaKdhS
@TheImaginativeSachin
@TheImaginativeSachin Жыл бұрын
Yay! I learnt something new today thanks mate. Completed!!!!
@marcinbiaecki9731
@marcinbiaecki9731 3 жыл бұрын
Thank you! Very helpful material 😀
@jaygarzon6709
@jaygarzon6709 3 жыл бұрын
I am here July 2021 Gonna comeback here after some years. You'll be part of it man. Thank you and keep making this type of videos you are awesome!
@TatataG
@TatataG 2 ай бұрын
where r u bro
@ZiclopDevices
@ZiclopDevices 2 жыл бұрын
Excellent tuto! Thanks for share.
@MateusMeurer
@MateusMeurer 3 жыл бұрын
Great vid bro, like always, vielen dank!
@meloukredouan6607
@meloukredouan6607 4 жыл бұрын
Thank you.... really good tutorial
@LaurinusPonpon
@LaurinusPonpon 3 жыл бұрын
Thanks a lot. My projet is a lot better now!
@peteroyelegbin
@peteroyelegbin 3 жыл бұрын
Thanks, great job! I tried to insert the data after following the video but it say unfortunately the app has stopped. What could be the problem and possible solution please?
@dutyman5533
@dutyman5533 3 жыл бұрын
Amazing keep on teaching
@mxhotta
@mxhotta 10 ай бұрын
Great job, excelent tutorial. Danke!!
@prakashanuvadia8870
@prakashanuvadia8870 3 жыл бұрын
nice easy explanation .....Kotlin tutorial is less so thanks for making Kotlin video ...it is possible data store in mobile in automatics daily convert in pdf and email on particular email when mobile is connected to internet ...i thought for this visitor list entry list in society ....Thanks
@metanormal
@metanormal 2 жыл бұрын
Question: Should the "set visibility to true" come as a last statement after the update of the RV is done, instead of being the first? Anyway: Great explanations, very detailed. Thank you. I will recommend. :-)
@NumCube
@NumCube 2 жыл бұрын
big thanks
@thahaziq97
@thahaziq97 2 жыл бұрын
Thank youu !!!
@MrLardmonkey
@MrLardmonkey 2 жыл бұрын
Good Stuff thanks for sharing.
@sharanpreetchadha3579
@sharanpreetchadha3579 3 жыл бұрын
Hey , the code shows no error but still when i press the button that leads to insertion of values into the table , i am getting a result of -1 from the db.insert() method . Can smone pls help me?
@maxhooker4186
@maxhooker4186 3 жыл бұрын
It works well, but when I change the add Record Form to a new activity, same parameters. Just made this small change. Then the app crashs. I dont change anything in the .kt files, (only import the new activity in MainActivity.kt, in order to avoid red flags. I check no red flags anywhere...after moved the add record form into a new activity and it crashes. the app dont even open.
@davidkitonga1058
@davidkitonga1058 3 жыл бұрын
i love your work buddy! but i got a querry, what can i do so that even if the number of records exceed 9 i can still add more records?
@macaronivirus5913
@macaronivirus5913 3 жыл бұрын
Where is the code of activity_main? There a lot of pieces missing, like images, contents of build.gradle, imports of MainActivity, ItemAdapter etc. can you just upload this to github or something, or should I buy the course to have access to full code? I have learnt something anyway just by watching the video, thank you.
@micahspecial5927
@micahspecial5927 3 жыл бұрын
able to use until this point" Output after inserting the employee record , " but toast out didnt appear after press the button
@GrooveMan21
@GrooveMan21 2 жыл бұрын
How about SQLite in a desktop Kotlin application? Suppose I want to access a SQLite database from Windows on my local hard drive. Is this code translatable to the desktop? "Room" is only usable inside an Android Context, so it cannot be used on the desktop. That's why this code is valuable if it can be used in a Windows program :-)
@TheImaginativeSachin
@TheImaginativeSachin Жыл бұрын
Hey guys this video was awesome, But I want to really understand SQLite a little bit more. Any other video worth mentioning to watch?
@kingfisher3791
@kingfisher3791 3 жыл бұрын
Why don't u use $ sign to insert variable in the string of creating table
@siddharajsinhrathod162
@siddharajsinhrathod162 2 жыл бұрын
Please can you tell me how can i store and retrieve rich text (bold/italic/underlined) in sqlitedb
@n.w.aicecube5713
@n.w.aicecube5713 2 жыл бұрын
Using volley to sync with mysql, both ends destination table a sync_status column for sync
@jorge8388
@jorge8388 3 жыл бұрын
Really good, have you explain with this example but how use webservice....sry my english
@MukkiBassist
@MukkiBassist 2 жыл бұрын
how to store database on external? like Facebook, Twitter. Use for online and export to BI.
@SudhanshuKumar-xy6xv
@SudhanshuKumar-xy6xv 3 жыл бұрын
Is the 90% offer still available ?
@Vin-nk3ee
@Vin-nk3ee 3 жыл бұрын
hi i really need help in this, can i have the full code in github?
@balajikrishnan8379
@balajikrishnan8379 2 жыл бұрын
thank you 😍
@tutorialsEU
@tutorialsEU 2 жыл бұрын
I see you like our content! I want to invite you to our community of testers, where we give our courses for a quality check. Please send me an email to evgenia@tutorials.eu with the subject line: testers community and your name in the body and I will add you
@orimouf9239
@orimouf9239 3 жыл бұрын
you are the best
@tutorialsEU
@tutorialsEU 3 жыл бұрын
Thanks Orim :)
@xerxesYt123
@xerxesYt123 2 жыл бұрын
Hello Please update the code for the newer version of android studio, there is now alot of errors
@avasam
@avasam 2 жыл бұрын
This tutorial is like reading from documents to students in the classroom. It was not a good idea. Coding tutorial should be done at the same time as coding
@Aditya-dv5wg
@Aditya-dv5wg 3 жыл бұрын
Amazing sir 🔥🔥🔥 and thanks for udemy courses I bought your both courses it is amazing and I enjoyed alot in learning from that....
@pierremarais7669
@pierremarais7669 2 жыл бұрын
Hi Denis, I have existing db which I use on my IOS app, I want to create the same app for android, how to do with the existing db in Android/Kotlin, thanks for your videos, I did purchase your masterclass, please help
@MrNerdie
@MrNerdie 2 жыл бұрын
why is the code in the site you gave different from the code in the video?
@gvharish9894
@gvharish9894 3 жыл бұрын
your website not working
@salahshakib2203
@salahshakib2203 3 жыл бұрын
Thank and great job but please 1 -how did your updateRecordDialog is working when writing updateDialog.the id of the item.setText() it didn't word with me 2- And also in MainActivity's onCreate() setSupportActionBar(toolbar) can't run 3- ItemAdapter.kt into the ViewHolder class var llMain = view.llMain view.llMain and other elements can't be written please please waiting for your answer it would be more better if you share the Project sources file on your website or on your Github Thanks agian
@VtmCoLtd
@VtmCoLtd 3 жыл бұрын
>> 3- ItemAdapter.kt into the ViewHolder class If you are using old Android Studio ver. You have to write that val llMain:LinearLayout = view.findViewById(R.id.llMain) val ivEdit: ImageView = view.findViewById(R.id.ivEdit) val ivDelete:ImageView = view.findViewById(R.id.ivDelete) ...
@cassiopeia1483
@cassiopeia1483 3 жыл бұрын
2. val toolbar: Toolbar = findViewById(R.id.toolbar) setSupportActionBar(toolbar)
@alberto4509
@alberto4509 2 жыл бұрын
Learning from mexico mate, in 15 nov I gotta present my app
@umarajmal6216
@umarajmal6216 2 жыл бұрын
how did it go
@micahspecial5927
@micahspecial5927 3 жыл бұрын
btnAdd.setOnClickListener where did u put this
@jonsmith6904
@jonsmith6904 3 жыл бұрын
The tutorials.eu site seems to be down?
@siphiworatsibe5609
@siphiworatsibe5609 3 жыл бұрын
Would you mind sharing the repository ;)
@shakhawathhussainkayes5241
@shakhawathhussainkayes5241 3 жыл бұрын
i am learning android development...which database should i learn room or SQLite? Please suggest 👏
@tusharjain7554
@tusharjain7554 3 жыл бұрын
ROOM
@paultreneary
@paultreneary 2 жыл бұрын
I tried the code from the article (testing it after each little section) but I got as far as 'Create a method to Add the record in the MainActivity.kt class' and after that it just throws compilation errors everywhere (etName not being recognized was one of the many) - I wonder if it's a 2022 Android Studio/Gradle problem. Maybe a github upload might be worthwhile? (BTW I tried adding a comment on the website but comments appear to have been blocked)
@ANNGUYEN-cw7lw
@ANNGUYEN-cw7lw 4 жыл бұрын
Hello instructor, can you build a dating app tutorial by android, it is same as Tinder app on youtube ?.
@tutorialsEU
@tutorialsEU 4 жыл бұрын
Arent there like 100 of those on youtube already? I will run a poll just before creating the next Android course, where a Tinder CLone will be one choice.
@gajendrapandeya5081
@gajendrapandeya5081 4 жыл бұрын
Don't you think sqlite is outdated And room is much better and preferred for Android You also have used sqlite in your udemy course
@viktorleskov7591
@viktorleskov7591 4 жыл бұрын
Just because he is oldman)
@tutorialsEU
@tutorialsEU 4 жыл бұрын
I'm a boomer ;) Room is on the list of topics that will be covered here (probably in 1-2 months).
@gajendrapandeya5081
@gajendrapandeya5081 4 жыл бұрын
@@viktorleskov7591 😂😂
@mohamadmaleki3026
@mohamadmaleki3026 8 ай бұрын
It was difficult for me and unfortunately I couldn't follow. Could you please explain it step by step from scratch?
@crumpfyllc5571
@crumpfyllc5571 4 жыл бұрын
Make video on Scope Storage and MediaStore
@tutorialsEU
@tutorialsEU 4 жыл бұрын
Thanks for the idea.
@McMansikka
@McMansikka 2 жыл бұрын
Everything explained well, but the code itself does NOT work anymore, so don't waste your time on this.
@md.shorifulhasan3149
@md.shorifulhasan3149 3 жыл бұрын
make this video again and show us step by step, this readymade code is not much useful to us.
@slayertommy301
@slayertommy301 Жыл бұрын
so this video doesnt even show us how to make the app hes showing off?
@franciszekciecholewski1824
@franciszekciecholewski1824 Жыл бұрын
46:26
@franciszekciecholewski1824
@franciszekciecholewski1824 Жыл бұрын
52:09
@Osegbuvalentine
@Osegbuvalentine Жыл бұрын
IMO, one of the worst tutorial I have seen for a newbie... You should be writing the codes not explaining the one you have already written....IMO.
@ziadhemmar7256
@ziadhemmar7256 Жыл бұрын
His KZfaq courses are so boring and nothing clear in them they are just an ad for his paid course Dislike
@indra_lingesh9457
@indra_lingesh9457 2 жыл бұрын
btnAdd.setOnClickListener is not working for me, its showing some error, can anybody xpalin this error, how to clear it??😰😰
@jmerhi
@jmerhi 3 жыл бұрын
After all Thank you is a great tutorial. I'm new on Kotlin and know a little Java. But the truth is that Kotlin, despite the fact that it is very good to make applications for android and they are written with much less code. It is very difficult to learn. Because so far I can't find a tutorial that can finish successfully. With this tutorial I was able to overcome several problems such as being able to make the ItemAdapter part you write: val llMain = view.llMain val tvEmail = view.tvEmail val ivEdit = view.ivEdit val ivDelete = view.ivDelete but that code does not work in Android Studio current version. For it to work I had to write it like this after googling: val llMain: LinearLayout = view.findViewById (R.id.llMain) as LinearLayout val tvName: TextView = view.findViewById (R.id.tvName) as TextView val tvEmail: TextView = view.findViewById (R.id.tvEmail) as TextView val ivEdit: ImageView = view.findViewById (R.id.ivEdit) as ImageView val ivDelete: ImageView = view.findViewById (R.id.ivDelete) as ImageView Now after finishing all the code for this application I find that when I run it. The RecyclerView only shows me the first record even though there are more than 5 records in my table. Could someone please help me with this? I would be very grateful.
@aldosoundrealm
@aldosoundrealm Жыл бұрын
For those who are having problems on View Holder, use val tvName: TextView = itemView.findViewById(R.id.tvName)
@TheImaginativeSachin
@TheImaginativeSachin Жыл бұрын
Hey if someone needs to know the theme to use for the update dialog use R.style.Theme_AppCompat_Dialog_MinWidth. It gives the same result as his.
SQLite Database for Android - Full Course
1:28:22
freeCodeCamp.org
Рет қаралды 247 М.
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 37 МЛН
Login and Signup using SQLite in Android Studio | Kotlin
34:18
Android Knowledge
Рет қаралды 10 М.
Is LEARNING WPF still WORTH it in 2023?
10:59
tutorialsEU
Рет қаралды 44 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 347 М.
Encrypt SQLite Databases with SQLCipher
14:58
NeuralNine
Рет қаралды 13 М.
Implementation of SQLite Database in Android using Kotlin
1:34:32
Dr. Parag Shukla
Рет қаралды 16 М.
SQLite Database Tutorial for Android Studio
1:27:08
Programming w/ Professor Sluiter
Рет қаралды 189 М.
DHH discusses SQLite (and Stoicism)
54:00
Aaron Francis
Рет қаралды 57 М.
Google Firebase Authentication Android Kotlin Tutorial
34:23
tutorialsEU
Рет қаралды 50 М.
Retrofit in Android Studio using Kotlin | Android Knowledge
19:05
Android Knowledge
Рет қаралды 5 М.
MongoDB Explained in 10 Minutes | SQL vs NoSQL | Jumpstart
11:18