0% found this document useful (0 votes)
56 views9 pages

Android Database Using Sqlite: 1 S.Renukadevi/Ap/Scd/Androiddatabase Using Sqlite June 28, 2021

The document discusses using SQLite as a database in Android applications. SQLite is a lightweight, relational database that does not require a separate server. It is included with Android and stores data in text format locally on the device. The document explains how to create and update a SQLite database using the SQLiteOpenHelper class. It also outlines steps to perform common SQLite operations like insert, read, delete and update data. The rest of the document contents include an example SQLite project in Android Studio.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views9 pages

Android Database Using Sqlite: 1 S.Renukadevi/Ap/Scd/Androiddatabase Using Sqlite June 28, 2021

The document discusses using SQLite as a database in Android applications. SQLite is a lightweight, relational database that does not require a separate server. It is included with Android and stores data in text format locally on the device. The document explains how to create and update a SQLite database using the SQLiteOpenHelper class. It also outlines steps to perform common SQLite operations like insert, read, delete and update data. The rest of the document contents include an example SQLite project in Android Studio.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 9

Android Database using

SQLite

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 1


SQLite Tutorial With Example In Android Studio

SQLite is a Structure query base database, open source, light weight, no network
access and standalone database. It support embedded relational database
features.

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 2


SQLite Tutorial With Example In Android Studio

•Whenever an application needs to store large amount of


data then using sqlite is more preferable than other repository
system like SharedPreferences or saving data in files.
•Android has built in SQLite database implementation.
•It is available locally over the device(mobile & tablet) and
contain data in text format.
•It carry light weight data and suitable with many languages.
So, it doesn’t required any administration or setup procedure
of the database.
Important Note – The database created is saved in a directory:
data/data/APP_Name/databases/DATABASE_NAME.

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 3


Table of Contents 

1 Creating And Updating Database In Android


2 SQLite Example In Android Studio
3 Add & Retrieve Image From SQLite
Database:

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 4


Creating And Updating Database In Android
SQLiteOpenHelper class
creating, updating and other operations you need to create a subclass or SQLiteOpenHelper
class
SQLiteOpenHelper is a helper class to manage database creation and version management.
It provides two methods onCreate(SQLiteDatabase db), onUpgrade(SQLiteDatabase db, int
oldVersion, int newVersion).

The SQLiteOpenHelper only require the DATABASE_NAME to create database


 After extending SQLiteOpenHelper you will need to implement its methods onCreate,
onUpgrade and constructor.

onCreate(SQLiteDatabase sqLiteDatabase)

method is called only once throughout the application lifecycle. It will be called whenever
there is a first call to getReadableDatabase() or getWritableDatabase() function available
in super SQLiteOpenHelper class. So SQLiteOpenHelper class call the onCreate() 
method after creating database and instantiate SQLiteDatabase object. Database name
is passed in constructor call.

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 5


Creating And Updating Database In Android
onUpgrade(SQLiteDatabase db,int oldVersion, int newVersion)
 whenever there is a updation in existing version. So to update a version we have to
increment the value of version variable passed in the superclass constructor.

In onUpgrade method we can write queries to perform whatever action is required. 

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 6


SQLite Example In Android Studio

Introduction To SQLite And Installation


List Of All Operators In SQLite
Data Type And Commands In SQLite
List Of All Clauses In SQLite For
Defining Specific Condition
Insert, Read, Delete & Update Operation
In SQLite

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 7


Step 1: Create a New Project and Name it SQLiteOperations.
Step 2: Open res -> layout -> activity_main.xml (or) main.xml and add
following code:
In this step we create a layout in our XML file adding textbox,
buttons, edittext. On button onclick is defined which associate it with
related function.

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 8


Thank You

June 28, 2021 S.RENUKADEVI/AP/SCD/ANDROIDDATABASE USING SQLITE 9

You might also like