No video

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

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

tutorialsEU

tutorialsEU

Күн бұрын

🚀 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/a...
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
RecyclerView | Everything You Need to Know
25:07
Practical Coding
Рет қаралды 135 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 4,3 МЛН
SQLite in Python || Python Tutorial || Learn Python Programming
10:11
Login and Signup using SQLite in Android Studio | Kotlin
34:18
Android Knowledge
Рет қаралды 10 М.
Encrypt SQLite Databases with SQLCipher
14:58
NeuralNine
Рет қаралды 13 М.
Retrofit in Android Studio using Kotlin | Android Knowledge
19:05
Android Knowledge
Рет қаралды 6 М.
Is LEARNING WPF still WORTH it in 2023?
10:59
tutorialsEU
Рет қаралды 48 М.
SQLite beginner crash course in Visual Studio Code - 2022
26:34
SQLite Database for Android - Full Course
1:28:22
freeCodeCamp.org
Рет қаралды 249 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 4,3 МЛН