SlideShare a Scribd company logo
1 of 22
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.

More Related Content

What's hot

Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
 
Sqlite
SqliteSqlite
SqliteKumar
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vbAmandeep Kaur
 
Java collections concept
Java collections conceptJava collections concept
Java collections conceptkumar gaurav
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
 
Introduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the WorldIntroduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the Worldjkreibich
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JSArno Lordkronos
 
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddelCHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddelmohamed khalaf alla mohamedain
 
android activity
android activityandroid activity
android activityDeepa Rani
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in GraphicsRajani Thite
 
Object Oriented Testing
Object Oriented TestingObject Oriented Testing
Object Oriented TestingAMITJain879
 

What's hot (20)

3D Display
3D Display3D Display
3D Display
 
Fragment
Fragment Fragment
Fragment
 
Database in Android
Database in AndroidDatabase in Android
Database in Android
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Android UI
Android UIAndroid UI
Android UI
 
Sqlite
SqliteSqlite
Sqlite
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vb
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Introduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the WorldIntroduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the World
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Java Beans
Java BeansJava Beans
Java Beans
 
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddelCHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
 
android activity
android activityandroid activity
android activity
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
 
Android Services
Android ServicesAndroid Services
Android Services
 
Object Oriented Testing
Object Oriented TestingObject Oriented Testing
Object Oriented Testing
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 

Viewers also liked

09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)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 SystemSQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management SystemTanner Jessel
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Khaled Anaqwa
 
Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorialinfo_zybotech
 
2011 06-sq lite-forensics
2011 06-sq lite-forensics2011 06-sq lite-forensics
2011 06-sq lite-forensicsviaForensics
 
Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)Lifeparticle
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqliteArif Huda
 
Better Data Persistence on Android
Better Data Persistence on AndroidBetter Data Persistence on Android
Better Data Persistence on AndroidEric Maxwell
 
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!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 7Android de la A a la Z - Unidad 7
Android de la A a la Z - Unidad 7Jorge Ulises
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in androidDurai S
 

Viewers also liked (20)

09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
 
SQLite - Overview
SQLite - OverviewSQLite - Overview
SQLite - Overview
 
Sqlite
SqliteSqlite
Sqlite
 
SQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management SystemSQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management System
 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
 
Aula 06 - TEP - Introdução SQLite
Aula 06 - TEP - Introdução SQLiteAula 06 - TEP - Introdução SQLite
Aula 06 - TEP - Introdução SQLite
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
 
SQLite
SQLiteSQLite
SQLite
 
Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorial
 
2011 06-sq lite-forensics
2011 06-sq lite-forensics2011 06-sq lite-forensics
2011 06-sq lite-forensics
 
Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)Tech Talk: App Functionality (Android)
Tech Talk: App Functionality (Android)
 
Android development beyond the basics
Android development   beyond the basicsAndroid development   beyond the basics
Android development beyond the basics
 
Sq lite
Sq lite Sq lite
Sq lite
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
 
Better Data Persistence on Android
Better Data Persistence on AndroidBetter Data Persistence on Android
Better Data Persistence on Android
 
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
SquiDB: a SQLite layer for Android - Jonathan Koren, Yahoo!
 
SQLite
SQLiteSQLite
SQLite
 
Android de la A a la Z - Unidad 7
Android de la A a la Z - Unidad 7Android de la A a la Z - Unidad 7
Android de la A a la Z - Unidad 7
 
SQLite3
SQLite3SQLite3
SQLite3
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in android
 

Similar to android sqlite

Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for AndroidJakir Hossain
 
Sql data base
Sql data baseSql data base
Sql data baseAli Jafar
 
SQLCLR For DBAs and Developers
SQLCLR For DBAs and DevelopersSQLCLR For DBAs and Developers
SQLCLR For DBAs and Developerswebhostingguy
 
Dr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. HydeDr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. Hydewebhostingguy
 
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginnersSQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginnersTobias Koprowski
 
Azure - Data Platform
Azure - Data PlatformAzure - Data Platform
Azure - Data Platformgiventocode
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlsqlhjalp
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptxKulbir4
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptxLadduAnanu
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Mark Ginnebaugh
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionDonRobins
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday SloveniaContinuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday SloveniaDr. John Tunnicliffe
 

Similar to android sqlite (20)

Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
 
Os Owens
Os OwensOs Owens
Os Owens
 
Sql data base
Sql data baseSql data base
Sql data base
 
Day2
Day2Day2
Day2
 
SQLCLR For DBAs and Developers
SQLCLR For DBAs and DevelopersSQLCLR For DBAs and Developers
SQLCLR For DBAs and Developers
 
Dr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. HydeDr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. Hyde
 
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginnersSQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
 
Azure - Data Platform
Azure - Data PlatformAzure - Data Platform
Azure - Data Platform
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdl
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
Sq lite
Sq liteSq lite
Sq lite
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptx
 
Sql lite presentation
Sql lite presentationSql lite presentation
Sql lite presentation
 
Sql Sever Presentation.pptx
Sql Sever Presentation.pptxSql Sever Presentation.pptx
Sql Sever Presentation.pptx
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact Edition
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday SloveniaContinuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
 

More from Deepa Rani

Speed controller of dc motor
Speed controller of dc motorSpeed controller of dc motor
Speed controller of dc motorDeepa Rani
 
Foot step power generator
Foot step power generatorFoot step power generator
Foot step power generatorDeepa Rani
 
Crime investigation system
Crime investigation systemCrime investigation system
Crime investigation systemDeepa Rani
 
android content providers
android content providersandroid content providers
android content providersDeepa Rani
 
android dilaogs
android dilaogsandroid dilaogs
android dilaogsDeepa Rani
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
android architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution processandroid architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution processDeepa Rani
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copyDeepa Rani
 
Android styles and themes
Android   styles and themesAndroid   styles and themes
Android styles and themesDeepa Rani
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structuresDeepa Rani
 
Fabric innovation
Fabric innovationFabric innovation
Fabric innovationDeepa Rani
 
Typical problem
Typical problemTypical problem
Typical problemDeepa Rani
 
straight line
straight line straight line
straight line Deepa Rani
 
Section of solids
Section of solidsSection of solids
Section of solidsDeepa Rani
 
Projection of solids
Projection of solidsProjection of solids
Projection of solidsDeepa Rani
 

More from Deepa Rani (20)

Speed controller of dc motor
Speed controller of dc motorSpeed controller of dc motor
Speed controller of dc motor
 
Foot step power generator
Foot step power generatorFoot step power generator
Foot step power generator
 
Crime investigation system
Crime investigation systemCrime investigation system
Crime investigation system
 
android content providers
android content providersandroid content providers
android content providers
 
android menus
android menusandroid menus
android menus
 
android dilaogs
android dilaogsandroid dilaogs
android dilaogs
 
android layouts
android layoutsandroid layouts
android layouts
 
android architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution processandroid architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution process
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
 
Android styles and themes
Android   styles and themesAndroid   styles and themes
Android styles and themes
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
 
Blue Brain
Blue BrainBlue Brain
Blue Brain
 
Tcp
TcpTcp
Tcp
 
Dc machiness
Dc machinessDc machiness
Dc machiness
 
Maddy android
Maddy androidMaddy android
Maddy android
 
Fabric innovation
Fabric innovationFabric innovation
Fabric innovation
 
Typical problem
Typical problemTypical problem
Typical problem
 
straight line
straight line straight line
straight line
 
Section of solids
Section of solidsSection of solids
Section of solids
 
Projection of solids
Projection of solidsProjection of solids
Projection of solids
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

android sqlite

  • 1.
  • 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.