SlideShare a Scribd company logo
3
Most read
4
Most read
7
Most read
android sqlite
Let us work with Sqlite
Table of contents
SNO Name Of Content
1 History Of SQLite Database
2 Why SQLite Only???
3 Features Of SQLite
4 Disadvantages Of SQLite
5 Architecture Of SQLite
6 Examples To Do
History
• SQlite is an open source embedded database. The original
implementation was designed by D. Richard Hipp.
• Hipp was designing software used on board guided
missile systems and thus had limited resources to work
with.
• The resulting design goals of SQLite were to allow the
program to be operated without a database installation
or administration.
Why Sqlite Only????
• In android we will use Sqlite database only . Because it is
in built DB in Android SDK more over it is lite weighted
relation DB suitable for Mobile Devices.
• We need not to load any drivers and we need not to
install the Sqlite separately.
• The queries also simple to understand and easy to
implement.
Feature of SQLite
• Application file format – Transactions guarantee ACID
[Atomicity, Consistency , Isolation, Durability] even after
system crashes and power failures.
• Temporary data analysis – Command line client, import
CSV files and use sql to analyze & generate reports .
• Embedded devices – Applicable to small, reliable and
portable like mobiles.
• Portable - uses only ANSI-standard C and VFS, file format
is cross platform (little vs. big endian, 32 vs. 64 bit)
Feature of SQLite
• Reliable – has 100% test coverage, open source code and
bug database, transactions are ACID even if power fails.
• Small – 300 kb library, runs in 16kb stack and 100kb heap.
• Single Database File – An SQLite database is a single
ordinary disk file that can be located anywhere in the
directory hierarchy.
• Readable source code – The source code to SQLite is
designed to be readable and accessible to the average
programmer.
Disadvantages
• High concurrency – reader/writer locks on the entire file.
• Huge datasets – DB file can’t exceed file system limit or
2TB.
• Access control – we don’t have any user interface to
operate Sqlite database objects as in MYSQL / SQL Server
/Oracle. All the objects are virtual. However there are
fewq third party UI are available in the market.
[http://www.sqlabs.net/sqlitemanager.php]
Architecture of Sqlite
Architecture of Sqlite
The SQL Command Processor will read the SQL Commands from
Interface and it will forward that SQL Query Strings to the
Tokenizer of SQL Compiler
This Virtual Machine will read the code what ever the code generated by the code
generator of the SQL Compiler
This interface will read the SQL queries what ever it is
generated by the user and it will pass this SQL Commands to
the SQL Command Processor
Architecture of Sqlite
When a string containing SQL statements is to be executed, the
interface passes that string to the tokenizer. The job of the
tokenizer is to break the original string up into tokens and pass
those tokens one by one to the parser. The tokenizer is hand-
coded in C in the file tokenize.c.
The parser is the piece that assigns meaning to tokens based on
their context, it does not leak memory when syntax errors are
encountered, parser assembles tokens into complete SQL
statements
the code generator to produce virtual machine code that will do the work that the SQL
statements request. Ex: vacuum.c and where.c in which where.c handles code generation
for WHERE clauses on SELECT, UPDATE and DELETE statements
Architecture of Sqlite
The B-tree module requests information from the disk in fixed-
size chunks. The default chunk size is 1024 bytes but can vary
between 512 and 65536 bytes. The page cache is responsible for
reading, writing, and caching these chunks. The page cache also
provides the rollback and atomic commit abstraction and takes
care of locking of the database file.
In order to provide portability between POSIX (Portable Operating System Interface (for
Unix))and Win32 operating systems, SQLite uses an abstraction layer to interface with the
operating system. The interface to the OS abstraction layer is defined in os.h.
An SQLite database is maintained on disk using a B-tree
implementation found in the btree.c source file. A separate B-tree
is used for each table and index in the database. All B-trees are
stored in the same disk file. Details of the file format are recorded
in a large comment at the beginning of btree.c.
Architecture of Sqlite
Memory allocation and ceaseless string comparison routines are
located in util.c
If you count regression test scripts, more than half the total code
base of SQLite is devoted to testing. There are many assert()
statements in the main code files
Examples To Do
Let us do some coding
Steps in working with Sqlite database:
 Creating Sqlite Object
 Creating Database
 Creating Table
 Working with Tables
Examples To Do
Let us do some coding
Step:1 Importing package
“android.database.sqlite.SQLiteDatabase”.
Step:2 Creating object
SQLiteDatabase object name=null;
Examples To Do
Let us do some coding
mydb=openOrCreateDatabase("DatabaseName5",
MODE_PRIVATE,null);
EX:
//mydb is sqlite object name .
//DatabaseName5 is nothing but database name
//MODE_PRIVATE is permissions of a table accessing
Examples To Do
Let us do some coding
mydb.execSQL("CREATE TABLE IF NOT EXISTS “
+TableName+" (ColumnName DataType);");
Examples To Do
Let us do some coding
Create:
mydb.execSQL("CREATE TABLE IF NOT EXISTS “
+TableName+" (ColumnName DataType);");
Alter:
ALTER TABLE TableName RENAME TO new-table-name
Drop:
DROP TABLE TableName
(View Source)
Examples To Do
Let us do some coding
Select:
Cursor c=mydb.rawQuery("SELECT * FROM "+TableName+"
where Name='"+city+"'",null);
Insert:
mydb.execSQL("INSERT INTO "+TableName+“ (Name, Area)“ +
"VALUES ('RedFort','40.8 acres‘);");
Delete:
mydb.execSQL(“Delete"+TableName);
(View Source)
SQLite OpenHelper
• SQLite OpenHelper is a class to manage database creation
and version management.
• This class take care of opening the database if it exists,
creating it if it does not, and upgrading it as necessary.
• This is for creating db “onCreate(SQLiteDataBase)”.
• when the database needs to be upgraded
“onUpgrade (SQLiteDataBase db, int oldVersion, int
newVersion)”.
• when the database has been opened
“onOpen (SQLiteDataBase db)”.
Examples To Do
The below are few kind of applications that we can develop using Sqlite in Android.
Ex:1. Find the registration
form in a Android application
given here.
Functional Description:
Once the user enters all the
details given and click on
Submit Button we need to
SAVE the entire data in
Sqllite using queries.
Examples To Do
The below are few kind of applications that we can develop using Sqlite in Android.
Ex:2. Find the List View in a
Android application given here.
Functional Description: Once
the user Stores The data ,You
have to read that data and show
In list view. Example if we have
all country names in the
Database then we can show as
here.
Examples To Do
The below are few kind of applications that we can develop using Sqlite in Android.
Ex:3. Find the Tab View in a
Android application given here.
Functional Description: Once
the user Stores The data ,You
have to read that data and show
In Tab View.
Ad

Recommended

SQLite database in android
SQLite database in android
Gourav Kumar Saini
 
SQLITE Android
SQLITE Android
Sourabh Sahu
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Ado.Net Tutorial
Ado.Net Tutorial
prabhu rajendran
 
ADO .Net
ADO .Net
DrSonali Vyas
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Entity framework code first
Entity framework code first
Confiz
 
ADO.NET
ADO.NET
Farzad Wadia
 
Spring Framework
Spring Framework
tola99
 
Event Handling in java
Event Handling in java
Google
 
Java Servlets
Java Servlets
BG Java EE Course
 
Java rmi
Java rmi
kamal kotecha
 
Angularjs PPT
Angularjs PPT
Amit Baghel
 
Sqlite
Sqlite
Raghu nath
 
Hibernate ppt
Hibernate ppt
Aneega
 
android menus
android menus
Deepa Rani
 
Mvc architecture
Mvc architecture
Surbhi Panhalkar
 
Java package
Java package
CS_GDRCST
 
Spring ppt
Spring ppt
Mumbai Academisc
 
Android activity lifecycle
Android activity lifecycle
Soham Patel
 
Delegates and events in C#
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
ASP.NET Web form
ASP.NET Web form
Md. Mahedee Hasan
 
Spring MVC Framework
Spring MVC Framework
Hùng Nguyễn Huy
 
Webservices
Webservices
Gerard Sylvester
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
Peter R. Egli
 
Introduction to .NET Framework
Introduction to .NET Framework
Raghuveer Guthikonda
 
Android adapters
Android adapters
baabtra.com - No. 1 supplier of quality freshers
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
SQLite - Overview
SQLite - Overview
Emanuele Bartolesi
 

More Related Content

What's hot (20)

ADO.NET
ADO.NET
Farzad Wadia
 
Spring Framework
Spring Framework
tola99
 
Event Handling in java
Event Handling in java
Google
 
Java Servlets
Java Servlets
BG Java EE Course
 
Java rmi
Java rmi
kamal kotecha
 
Angularjs PPT
Angularjs PPT
Amit Baghel
 
Sqlite
Sqlite
Raghu nath
 
Hibernate ppt
Hibernate ppt
Aneega
 
android menus
android menus
Deepa Rani
 
Mvc architecture
Mvc architecture
Surbhi Panhalkar
 
Java package
Java package
CS_GDRCST
 
Spring ppt
Spring ppt
Mumbai Academisc
 
Android activity lifecycle
Android activity lifecycle
Soham Patel
 
Delegates and events in C#
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
ASP.NET Web form
ASP.NET Web form
Md. Mahedee Hasan
 
Spring MVC Framework
Spring MVC Framework
Hùng Nguyễn Huy
 
Webservices
Webservices
Gerard Sylvester
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
Peter R. Egli
 
Introduction to .NET Framework
Introduction to .NET Framework
Raghuveer Guthikonda
 
Android adapters
Android adapters
baabtra.com - No. 1 supplier of quality freshers
 

Viewers also liked (20)

09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
SQLite - Overview
SQLite - Overview
Emanuele Bartolesi
 
SQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management System
Tanner Jessel
 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Aula 06 - TEP - Introdução SQLite
Aula 06 - TEP - Introdução SQLite
Anderson Fabiano Dums
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
Khaled Anaqwa
 
SQLite
SQLite
maymania
 
Android database tutorial
Android database tutorial
info_zybotech
 
2011 06-sq lite-forensics
2011 06-sq lite-forensics
viaForensics
 
Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)
Lifeparticle
 
Android development beyond the basics
Android development beyond the basics
Vanjikumaran Sivajothy
 
Sq lite
Sq lite
RAUL Velez
 
Persitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
Better Data Persistence on Android
Better Data Persistence on Android
Eric Maxwell
 
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
DroidConTLV
 
SQLite
SQLite
Edniizz Quisol
 
Android de la A a la Z - Unidad 7
Android de la A a la Z - Unidad 7
Jorge Ulises
 
SQLite3
SQLite3
Andrés Ignacio Martínez Soto
 
Alertdialog in android
Alertdialog in android
Durai S
 
Sq lite presentation
Sq lite presentation
Prof. Erwin Globio
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
SQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management System
Tanner Jessel
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
Khaled Anaqwa
 
Android database tutorial
Android database tutorial
info_zybotech
 
2011 06-sq lite-forensics
2011 06-sq lite-forensics
viaForensics
 
Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)
Lifeparticle
 
Persitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
Better Data Persistence on Android
Better Data Persistence on Android
Eric Maxwell
 
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
DroidConTLV
 
Android de la A a la Z - Unidad 7
Android de la A a la Z - Unidad 7
Jorge Ulises
 
Alertdialog in android
Alertdialog in android
Durai S
 
Ad

Similar to android sqlite (20)

Sql data base
Sql data base
Ali Jafar
 
Sq lite database
Sq lite database
AYESHA JAVED
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for Android
Jakir Hossain
 
Os Owens
Os Owens
oscon2007
 
Sq lite
Sq lite
vinoth raj
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptx
vishal choudhary
 
Sq lite
Sq lite
IFADHA KADI
 
Android Level 2
Android Level 2
DevMix
 
Android webinar class_6
Android webinar class_6
Edureka!
 
Sqlite
Sqlite
Kumar
 
Android sq lite-chapter 22
Android sq lite-chapter 22
Dr. Ramkumar Lakshminarayanan
 
Sq lite
Sq lite
Revuru Bharadwaja
 
Android-Chapter17-SQL-Data persistency in android databases
Android-Chapter17-SQL-Data persistency in android databases
RyanAguirre5
 
Contains the SQLite database management classes that an application would use...
Contains the SQLite database management classes that an application would use...
GabrielPachasAlvarad
 
SQLite.pptx
SQLite.pptx
MirzaHammad12
 
Implementation of sql server based on sqlite engine on
Implementation of sql server based on sqlite engine on
eSAT Publishing House
 
Android Database
Android Database
Rashad Aliyev
 
Sql lite presentation
Sql lite presentation
shubham julaha
 
Database
Database
nationalmobileapps
 
Lecture 10: Android SQLite database.pptx
Lecture 10: Android SQLite database.pptx
Yousef Alamir
 
Sql data base
Sql data base
Ali Jafar
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for Android
Jakir Hossain
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptx
vishal choudhary
 
Android Level 2
Android Level 2
DevMix
 
Android webinar class_6
Android webinar class_6
Edureka!
 
Sqlite
Sqlite
Kumar
 
Android-Chapter17-SQL-Data persistency in android databases
Android-Chapter17-SQL-Data persistency in android databases
RyanAguirre5
 
Contains the SQLite database management classes that an application would use...
Contains the SQLite database management classes that an application would use...
GabrielPachasAlvarad
 
Implementation of sql server based on sqlite engine on
Implementation of sql server based on sqlite engine on
eSAT Publishing House
 
Lecture 10: Android SQLite database.pptx
Lecture 10: Android SQLite database.pptx
Yousef Alamir
 
Ad

More from Deepa Rani (20)

Speed controller of dc motor
Speed controller of dc motor
Deepa Rani
 
Foot step power generator
Foot step power generator
Deepa Rani
 
Crime investigation system
Crime investigation system
Deepa Rani
 
android content providers
android content providers
Deepa Rani
 
android dilaogs
android dilaogs
Deepa Rani
 
android layouts
android layouts
Deepa Rani
 
android activity
android activity
Deepa Rani
 
android architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution process
Deepa Rani
 
Android the first app - hello world - copy
Android the first app - hello world - copy
Deepa Rani
 
Android styles and themes
Android styles and themes
Deepa Rani
 
Review of basic data structures
Review of basic data structures
Deepa Rani
 
Blue Brain
Blue Brain
Deepa Rani
 
Tcp
Tcp
Deepa Rani
 
Dc machiness
Dc machiness
Deepa Rani
 
Maddy android
Maddy android
Deepa Rani
 
Fabric innovation
Fabric innovation
Deepa Rani
 
Typical problem
Typical problem
Deepa Rani
 
straight line
straight line
Deepa Rani
 
Section of solids
Section of solids
Deepa Rani
 
Projection of solids
Projection of solids
Deepa Rani
 
Speed controller of dc motor
Speed controller of dc motor
Deepa Rani
 
Foot step power generator
Foot step power generator
Deepa Rani
 
Crime investigation system
Crime investigation system
Deepa Rani
 
android content providers
android content providers
Deepa Rani
 
android dilaogs
android dilaogs
Deepa Rani
 
android layouts
android layouts
Deepa Rani
 
android activity
android activity
Deepa Rani
 
android architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution process
Deepa Rani
 
Android the first app - hello world - copy
Android the first app - hello world - copy
Deepa Rani
 
Android styles and themes
Android styles and themes
Deepa Rani
 
Review of basic data structures
Review of basic data structures
Deepa Rani
 
Fabric innovation
Fabric innovation
Deepa Rani
 
Typical problem
Typical problem
Deepa Rani
 
straight line
straight line
Deepa Rani
 
Section of solids
Section of solids
Deepa Rani
 
Projection of solids
Projection of solids
Deepa Rani
 

Recently uploaded (20)

2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
How to use search fetch method in Odoo 18
How to use search fetch method in Odoo 18
Celine George
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
Peer Teaching Observations During School Internship
Peer Teaching Observations During School Internship
AjayaMohanty7
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
How to use search fetch method in Odoo 18
How to use search fetch method in Odoo 18
Celine George
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
Peer Teaching Observations During School Internship
Peer Teaching Observations During School Internship
AjayaMohanty7
 

android sqlite

  • 2. Let us work with Sqlite Table of contents SNO Name Of Content 1 History Of SQLite Database 2 Why SQLite Only??? 3 Features Of SQLite 4 Disadvantages Of SQLite 5 Architecture Of SQLite 6 Examples To Do
  • 3. History • SQlite is an open source embedded database. The original implementation was designed by D. Richard Hipp. • Hipp was designing software used on board guided missile systems and thus had limited resources to work with. • The resulting design goals of SQLite were to allow the program to be operated without a database installation or administration.
  • 4. Why Sqlite Only???? • In android we will use Sqlite database only . Because it is in built DB in Android SDK more over it is lite weighted relation DB suitable for Mobile Devices. • We need not to load any drivers and we need not to install the Sqlite separately. • The queries also simple to understand and easy to implement.
  • 5. Feature of SQLite • Application file format – Transactions guarantee ACID [Atomicity, Consistency , Isolation, Durability] even after system crashes and power failures. • Temporary data analysis – Command line client, import CSV files and use sql to analyze & generate reports . • Embedded devices – Applicable to small, reliable and portable like mobiles. • Portable - uses only ANSI-standard C and VFS, file format is cross platform (little vs. big endian, 32 vs. 64 bit)
  • 6. Feature of SQLite • Reliable – has 100% test coverage, open source code and bug database, transactions are ACID even if power fails. • Small – 300 kb library, runs in 16kb stack and 100kb heap. • Single Database File – An SQLite database is a single ordinary disk file that can be located anywhere in the directory hierarchy. • Readable source code – The source code to SQLite is designed to be readable and accessible to the average programmer.
  • 7. Disadvantages • High concurrency – reader/writer locks on the entire file. • Huge datasets – DB file can’t exceed file system limit or 2TB. • Access control – we don’t have any user interface to operate Sqlite database objects as in MYSQL / SQL Server /Oracle. All the objects are virtual. However there are fewq third party UI are available in the market. [http://www.sqlabs.net/sqlitemanager.php]
  • 9. Architecture of Sqlite The SQL Command Processor will read the SQL Commands from Interface and it will forward that SQL Query Strings to the Tokenizer of SQL Compiler This Virtual Machine will read the code what ever the code generated by the code generator of the SQL Compiler This interface will read the SQL queries what ever it is generated by the user and it will pass this SQL Commands to the SQL Command Processor
  • 10. Architecture of Sqlite When a string containing SQL statements is to be executed, the interface passes that string to the tokenizer. The job of the tokenizer is to break the original string up into tokens and pass those tokens one by one to the parser. The tokenizer is hand- coded in C in the file tokenize.c. The parser is the piece that assigns meaning to tokens based on their context, it does not leak memory when syntax errors are encountered, parser assembles tokens into complete SQL statements the code generator to produce virtual machine code that will do the work that the SQL statements request. Ex: vacuum.c and where.c in which where.c handles code generation for WHERE clauses on SELECT, UPDATE and DELETE statements
  • 11. Architecture of Sqlite The B-tree module requests information from the disk in fixed- size chunks. The default chunk size is 1024 bytes but can vary between 512 and 65536 bytes. The page cache is responsible for reading, writing, and caching these chunks. The page cache also provides the rollback and atomic commit abstraction and takes care of locking of the database file. In order to provide portability between POSIX (Portable Operating System Interface (for Unix))and Win32 operating systems, SQLite uses an abstraction layer to interface with the operating system. The interface to the OS abstraction layer is defined in os.h. An SQLite database is maintained on disk using a B-tree implementation found in the btree.c source file. A separate B-tree is used for each table and index in the database. All B-trees are stored in the same disk file. Details of the file format are recorded in a large comment at the beginning of btree.c.
  • 12. Architecture of Sqlite Memory allocation and ceaseless string comparison routines are located in util.c If you count regression test scripts, more than half the total code base of SQLite is devoted to testing. There are many assert() statements in the main code files
  • 13. Examples To Do Let us do some coding Steps in working with Sqlite database:  Creating Sqlite Object  Creating Database  Creating Table  Working with Tables
  • 14. Examples To Do Let us do some coding Step:1 Importing package “android.database.sqlite.SQLiteDatabase”. Step:2 Creating object SQLiteDatabase object name=null;
  • 15. Examples To Do Let us do some coding mydb=openOrCreateDatabase("DatabaseName5", MODE_PRIVATE,null); EX: //mydb is sqlite object name . //DatabaseName5 is nothing but database name //MODE_PRIVATE is permissions of a table accessing
  • 16. Examples To Do Let us do some coding mydb.execSQL("CREATE TABLE IF NOT EXISTS “ +TableName+" (ColumnName DataType);");
  • 17. Examples To Do Let us do some coding Create: mydb.execSQL("CREATE TABLE IF NOT EXISTS “ +TableName+" (ColumnName DataType);"); Alter: ALTER TABLE TableName RENAME TO new-table-name Drop: DROP TABLE TableName (View Source)
  • 18. Examples To Do Let us do some coding Select: Cursor c=mydb.rawQuery("SELECT * FROM "+TableName+" where Name='"+city+"'",null); Insert: mydb.execSQL("INSERT INTO "+TableName+“ (Name, Area)“ + "VALUES ('RedFort','40.8 acres‘);"); Delete: mydb.execSQL(“Delete"+TableName); (View Source)
  • 19. SQLite OpenHelper • SQLite OpenHelper is a class to manage database creation and version management. • This class take care of opening the database if it exists, creating it if it does not, and upgrading it as necessary. • This is for creating db “onCreate(SQLiteDataBase)”. • when the database needs to be upgraded “onUpgrade (SQLiteDataBase db, int oldVersion, int newVersion)”. • when the database has been opened “onOpen (SQLiteDataBase db)”.
  • 20. Examples To Do The below are few kind of applications that we can develop using Sqlite in Android. Ex:1. Find the registration form in a Android application given here. Functional Description: Once the user enters all the details given and click on Submit Button we need to SAVE the entire data in Sqllite using queries.
  • 21. Examples To Do The below are few kind of applications that we can develop using Sqlite in Android. Ex:2. Find the List View in a Android application given here. Functional Description: Once the user Stores The data ,You have to read that data and show In list view. Example if we have all country names in the Database then we can show as here.
  • 22. Examples To Do The below are few kind of applications that we can develop using Sqlite in Android. Ex:3. Find the Tab View in a Android application given here. Functional Description: Once the user Stores The data ,You have to read that data and show In Tab View.