SlideShare a Scribd company logo
Lecture 5: Storage: Saving Data
Database, Files & Preferences [1]
Ahsanul Karim
karim.ahsanul@gmail.com
http://droidtraining.wordpress.com
Android Application Development
1. Storage Options
2. Saving Data into a Database
a. Introduction to SQLite
b. SQL Helper Database Creation
c. CRUD [Create Read Update Delete]
3. Using a Pre-populated Database
4. Some optimizations
Saving Data Storage Options
Options to save persistent application data:
[1] Shared Preferences:
Store private primitive data in key-value pairs.
[2] Internal Storage:
Store private data on the device memory.
[3] External Storage:
Store public data on the shared external storage.
[4] SQLite Databases:
Store structured data in a private database.
[5] Network Connection:
Store data on the web with your network server.
Saving Data Today We’ll Discuss...
1. Saving Data into Database
a. Introduction to SQLite
b. SQLiteOpenHelper: Database Creation
c. CRUD [Create Read Update Delete]
2. Using a Pre-populated Database
3. Some optimizations
Saving Data into a Database
Introduction to SQLite
[1]
SQLite is a software library that implements SQL database engine
[1] Self-contained:
Requires very minimal support from external libraries or from the
operating system. (well suited for embedded devices)
[2] Serverless:
No separate server process like most SQL database implementations
(MySql, Oracle etc.). The process that wants to access the database
reads and writes directly from the database files on disk.
[3] Zero-configuration:
Does not need to be "installed". There is no "setup" procedure. There is
no server process that needs to be started, stopped, or configured. No
need for an administrator to create a new database instance or assign
access permissions to users.
[4] Transactional:
All changes and queries appear to be Atomic, Consistent, Isolated, and
Durable (ACID)
Saving Data into a Database
Introduction to SQLite
[2]
Features:
1. Self-contained, Serverless, Zero-configuration and Transactional
2. A complete database is stored in a single cross-platform disk file.
3. Supports terabyte-sized databases and gigabyte-sized strings and
blobs.
4. Small code footprint
5. Faster than popular client/server database engines for most
operations.
6. Simple, easy to use API.
7. Written in ANSI-C.
8. Cross-platform: Unix (Linux, Mac OS-X, Android, iOS) and Windows
(Win32, WinCE, WinRT) are supported out of the box. Easy to port to
other systems.
9. Sources are in the public domain. Use for any purpose.
10. Comes with a standalone command-line interface (CLI) client that
can be used to administer SQLite databases.
Saving Data into a Database Introduction to SQL [1]
Basic database concepts:
[1] What is SQL?
SQL stands for Structured Query Language
SQL lets you access and manipulate databases
[2] What Can SQL do?
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and views
http://www.w3schools.com/sql/sql_intro.asp
Saving Data into a Database Introduction to SQL [3]
[3] Relational Database Management System (RDBMS)
1. RDBMS stands for Relational Database Management System.
2. RDBMS is the basis for SQL, and for all modern database systems
such as MS SQL Server, IBM DB2, Oracle, MySQL, Microsoft Access
and SQLite.
3. The data in RDBMS is stored in database objects called tables.
4. A table is a collection of related data entries and it consists of
columns and rows.
http://www.w3schools.com/sql/sql_intro.asp
Let’s have a quick look in SQL first...
Saving Data into a Database Introduction to SQL [4]
[4] RDBMS Example
Saving Data into a Database Introduction to SQL [5]
[4] RDBMS Example
Saving Data into a Database Introduction to SQL [6]
[5] Database operations
1. Database creation
2. Table(s) creation
3. Insert Record(s)
4. Update Record(s)
5. Delete Record(s)
6. Query
7. Drop Table(s)
8. Alter Table(s)
SELECT - extracts data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index
[6] SQL Commands
Saving Data into a Database Introduction to SQL [7]
[7] Example SQL Commands
CREATE TABLE IF NOT EXISTS `employee` (
`EmployeeID` int(11) NOT NULL
AUTO_INCREMENT,
`Name` varchar(50) NOT NULL,
`Address` varchar(100) NOT NULL,
`PhoneNumber` varchar(11) NOT NULL,
`Designation` varchar(50) NOT NULL,
PRIMARY KEY (`EmployeeID`)
);
[a] Table Creation
Saving Data into a Database Introduction to SQL [8]
[7] Example SQL Commands
INSERT INTO employee (EmployeeID, Name,
Address, PhoneNumber, Designation) VALUES
(NULL, 'Hasan', 'Mirpur, Dhaka', '01745534',
'Developer');
INSERT INTO employee (EmployeeID, Name,
Address, PhoneNumber, Designation) VALUES
(NULL, 'Rahim', 'Motijheel, Dhaka', '01956635',
'Designer');
[a] Insert Records
Saving Data into a Database Introduction to SQL [9]
[7] Example SQL Commands
SELECT * FROM employee;
SELECT Name, Address FROM employee;
SELECT * FROM employee WHERE EmployeeID = 1;
SELECT * FROM employee WHERE Designation =
‘Developer’;
[b] Query Records
Saving Data into a Database SQLite in Android
Saving Data into a Database Questions...
Man who waits for roast duck to fly into mouth
must wait very, very long time.
-Chinese Proverb

More Related Content

What's hot (20)

PDF
Pillars of Heterogeneous HDFS Storage
Pete Kisich
 
PPTX
Big file tablespaces
dev3993
 
PPTX
MongoDB for Beginners
Enoch Joshua
 
PPTX
Hadoop distributed file system
Ameya Vijay Gokhale
 
PDF
iOS: Using persistant storage
Jussi Pohjolainen
 
PPTX
Sql Health in a SharePoint environment
Enrique Lima
 
PPTX
MongoDB-SESION01
Jainul Musani
 
PPTX
Redis database
Ñáwrás Ñzár
 
PDF
Introduction to mongo db
Rohit Bishnoi
 
PPTX
Connecting to my sql using PHP
Nisa Soomro
 
PDF
Android Level 2
DevMix
 
PPT
SSDs - Improving Performance of Storage Arrays
nomathjobs
 
PPTX
Accesso ai dati con Azure Data Platform
Luca Di Fino
 
PDF
Intro To Couch Db
Shahar Evron
 
PPTX
Hadoop introduction seminar presentation
puneet yadav
 
PPTX
MongoDB-SESSION02
Jainul Musani
 
PPTX
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
DataWorks Summit
 
PDF
How Clean is your database? Data scrubbing for all skills sets
Chad Petrovay
 
PPTX
Connecting NodeJS & MongoDB
Enoch Joshua
 
PPT
Mongo DB for Java, Python and PHP Developers
Rick Hightower
 
Pillars of Heterogeneous HDFS Storage
Pete Kisich
 
Big file tablespaces
dev3993
 
MongoDB for Beginners
Enoch Joshua
 
Hadoop distributed file system
Ameya Vijay Gokhale
 
iOS: Using persistant storage
Jussi Pohjolainen
 
Sql Health in a SharePoint environment
Enrique Lima
 
MongoDB-SESION01
Jainul Musani
 
Redis database
Ñáwrás Ñzár
 
Introduction to mongo db
Rohit Bishnoi
 
Connecting to my sql using PHP
Nisa Soomro
 
Android Level 2
DevMix
 
SSDs - Improving Performance of Storage Arrays
nomathjobs
 
Accesso ai dati con Azure Data Platform
Luca Di Fino
 
Intro To Couch Db
Shahar Evron
 
Hadoop introduction seminar presentation
puneet yadav
 
MongoDB-SESSION02
Jainul Musani
 
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
DataWorks Summit
 
How Clean is your database? Data scrubbing for all skills sets
Chad Petrovay
 
Connecting NodeJS & MongoDB
Enoch Joshua
 
Mongo DB for Java, Python and PHP Developers
Rick Hightower
 

Viewers also liked (20)

PPTX
Android Workshop Day 1 Part 2
Ahsanul Karim
 
PPTX
Android 1.8 sensor
Ahsanul Karim
 
PDF
List Views
Ahsanul Karim
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
PDF
Day 2 android internals a quick overview
Ahsanul Karim
 
PPT
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
PPTX
Creating the first app with android studio
Parinita03
 
PPT
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
PDF
Day 1 Android: Before Getting Started
Ahsanul Karim
 
PPT
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
PDF
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
PPTX
Client-Server
Ahsanul Karim
 
PPTX
Android before getting started
Ahsanul Karim
 
PDF
AndroidManifest
Ahsanul Karim
 
PDF
Ui layout (incomplete)
Ahsanul Karim
 
PDF
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
PPTX
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
PPT
Multiple Activity and Navigation Primer
Ahsanul Karim
 
PPTX
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
PPT
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Android Workshop Day 1 Part 2
Ahsanul Karim
 
Android 1.8 sensor
Ahsanul Karim
 
List Views
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 2 android internals a quick overview
Ahsanul Karim
 
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
Creating the first app with android studio
Parinita03
 
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
Day 1 Android: Before Getting Started
Ahsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
Client-Server
Ahsanul Karim
 
Android before getting started
Ahsanul Karim
 
AndroidManifest
Ahsanul Karim
 
Ui layout (incomplete)
Ahsanul Karim
 
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
Multiple Activity and Navigation Primer
Ahsanul Karim
 
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Ad

Similar to Lecture 5: Storage: Saving Data Database, Files & Preferences (20)

PDF
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Amanda Lam
 
DOCX
Android project (1)
hamzaterghini
 
PPTX
Data Manipulation ppt. for BSIT students
julie4baxtii
 
PPT
Cdocumentsandsettingsuser1desktop2 dbmsexamples-091012013049-phpapp01
Raza Baloch
 
PPT
DBMS an Example
Dr. C.V. Suresh Babu
 
PDF
Complete SQL in one video by shradha.pdf
rahulashu699
 
PDF
Sqlite tutorial
Diogenes Silva Sousa
 
PDF
Sqlite tutorial
Aravindharamanan S
 
PPTX
Database management system
Sayed Ahmed
 
PPTX
Database management system
Sayed Ahmed
 
PDF
Sq lite module5
Highervista
 
PPTX
Dbms and sqlpptx
thesupermanreturns
 
PPTX
Sq lite
vinoth raj
 
PPTX
English database management_system
Sayed Ahmed
 
PPTX
Computer class of agriculture production 5.pptx
muddydevil2003
 
PPTX
Presentation DBMS (1)
Ali Raza
 
DOCX
DBMS PART 1.docx
GudduKumar408051
 
PPT
Database management system basics and it applications
RAJESH S
 
PPTX
Basic of Database Management System(DBMS)
anjanasharma77573
 
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Amanda Lam
 
Android project (1)
hamzaterghini
 
Data Manipulation ppt. for BSIT students
julie4baxtii
 
Cdocumentsandsettingsuser1desktop2 dbmsexamples-091012013049-phpapp01
Raza Baloch
 
DBMS an Example
Dr. C.V. Suresh Babu
 
Complete SQL in one video by shradha.pdf
rahulashu699
 
Sqlite tutorial
Diogenes Silva Sousa
 
Sqlite tutorial
Aravindharamanan S
 
Database management system
Sayed Ahmed
 
Database management system
Sayed Ahmed
 
Sq lite module5
Highervista
 
Dbms and sqlpptx
thesupermanreturns
 
Sq lite
vinoth raj
 
English database management_system
Sayed Ahmed
 
Computer class of agriculture production 5.pptx
muddydevil2003
 
Presentation DBMS (1)
Ali Raza
 
DBMS PART 1.docx
GudduKumar408051
 
Database management system basics and it applications
RAJESH S
 
Basic of Database Management System(DBMS)
anjanasharma77573
 
Ad

More from Ahsanul Karim (14)

PDF
Lecture 3 getting active through activities
Ahsanul Karim
 
PDF
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
PPTX
Day 15: Working in Background
Ahsanul Karim
 
PPTX
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
PPT
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
DOC
Day 4: Activity lifecycle
Ahsanul Karim
 
PPT
Day 4: Android: UI Widgets
Ahsanul Karim
 
PDF
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
PDF
GCM for Android
Ahsanul Karim
 
PDF
Sensors in Android (old)
Ahsanul Karim
 
PDF
Day1 before getting_started
Ahsanul Karim
 
PPTX
Action Bar Sherlock tutorial
Ahsanul Karim
 
PPTX
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
Lecture 3 getting active through activities
Ahsanul Karim
 
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
Day 15: Working in Background
Ahsanul Karim
 
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
Day 4: Activity lifecycle
Ahsanul Karim
 
Day 4: Android: UI Widgets
Ahsanul Karim
 
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
GCM for Android
Ahsanul Karim
 
Sensors in Android (old)
Ahsanul Karim
 
Day1 before getting_started
Ahsanul Karim
 
Action Bar Sherlock tutorial
Ahsanul Karim
 
Android Workshop: Day 1 Part 3
Ahsanul Karim
 

Recently uploaded (20)

PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 

Lecture 5: Storage: Saving Data Database, Files & Preferences

  • 1. Lecture 5: Storage: Saving Data Database, Files & Preferences [1] Ahsanul Karim [email protected] http://droidtraining.wordpress.com Android Application Development 1. Storage Options 2. Saving Data into a Database a. Introduction to SQLite b. SQL Helper Database Creation c. CRUD [Create Read Update Delete] 3. Using a Pre-populated Database 4. Some optimizations
  • 2. Saving Data Storage Options Options to save persistent application data: [1] Shared Preferences: Store private primitive data in key-value pairs. [2] Internal Storage: Store private data on the device memory. [3] External Storage: Store public data on the shared external storage. [4] SQLite Databases: Store structured data in a private database. [5] Network Connection: Store data on the web with your network server.
  • 3. Saving Data Today We’ll Discuss... 1. Saving Data into Database a. Introduction to SQLite b. SQLiteOpenHelper: Database Creation c. CRUD [Create Read Update Delete] 2. Using a Pre-populated Database 3. Some optimizations
  • 4. Saving Data into a Database Introduction to SQLite [1] SQLite is a software library that implements SQL database engine [1] Self-contained: Requires very minimal support from external libraries or from the operating system. (well suited for embedded devices) [2] Serverless: No separate server process like most SQL database implementations (MySql, Oracle etc.). The process that wants to access the database reads and writes directly from the database files on disk. [3] Zero-configuration: Does not need to be "installed". There is no "setup" procedure. There is no server process that needs to be started, stopped, or configured. No need for an administrator to create a new database instance or assign access permissions to users. [4] Transactional: All changes and queries appear to be Atomic, Consistent, Isolated, and Durable (ACID)
  • 5. Saving Data into a Database Introduction to SQLite [2] Features: 1. Self-contained, Serverless, Zero-configuration and Transactional 2. A complete database is stored in a single cross-platform disk file. 3. Supports terabyte-sized databases and gigabyte-sized strings and blobs. 4. Small code footprint 5. Faster than popular client/server database engines for most operations. 6. Simple, easy to use API. 7. Written in ANSI-C. 8. Cross-platform: Unix (Linux, Mac OS-X, Android, iOS) and Windows (Win32, WinCE, WinRT) are supported out of the box. Easy to port to other systems. 9. Sources are in the public domain. Use for any purpose. 10. Comes with a standalone command-line interface (CLI) client that can be used to administer SQLite databases.
  • 6. Saving Data into a Database Introduction to SQL [1] Basic database concepts: [1] What is SQL? SQL stands for Structured Query Language SQL lets you access and manipulate databases [2] What Can SQL do? SQL can execute queries against a database SQL can retrieve data from a database SQL can insert records in a database SQL can update records in a database SQL can delete records from a database SQL can create new databases SQL can create new tables in a database SQL can create stored procedures in a database SQL can create views in a database SQL can set permissions on tables, procedures, and views http://www.w3schools.com/sql/sql_intro.asp
  • 7. Saving Data into a Database Introduction to SQL [3] [3] Relational Database Management System (RDBMS) 1. RDBMS stands for Relational Database Management System. 2. RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, Microsoft Access and SQLite. 3. The data in RDBMS is stored in database objects called tables. 4. A table is a collection of related data entries and it consists of columns and rows. http://www.w3schools.com/sql/sql_intro.asp Let’s have a quick look in SQL first...
  • 8. Saving Data into a Database Introduction to SQL [4] [4] RDBMS Example
  • 9. Saving Data into a Database Introduction to SQL [5] [4] RDBMS Example
  • 10. Saving Data into a Database Introduction to SQL [6] [5] Database operations 1. Database creation 2. Table(s) creation 3. Insert Record(s) 4. Update Record(s) 5. Delete Record(s) 6. Query 7. Drop Table(s) 8. Alter Table(s) SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index [6] SQL Commands
  • 11. Saving Data into a Database Introduction to SQL [7] [7] Example SQL Commands CREATE TABLE IF NOT EXISTS `employee` ( `EmployeeID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(50) NOT NULL, `Address` varchar(100) NOT NULL, `PhoneNumber` varchar(11) NOT NULL, `Designation` varchar(50) NOT NULL, PRIMARY KEY (`EmployeeID`) ); [a] Table Creation
  • 12. Saving Data into a Database Introduction to SQL [8] [7] Example SQL Commands INSERT INTO employee (EmployeeID, Name, Address, PhoneNumber, Designation) VALUES (NULL, 'Hasan', 'Mirpur, Dhaka', '01745534', 'Developer'); INSERT INTO employee (EmployeeID, Name, Address, PhoneNumber, Designation) VALUES (NULL, 'Rahim', 'Motijheel, Dhaka', '01956635', 'Designer'); [a] Insert Records
  • 13. Saving Data into a Database Introduction to SQL [9] [7] Example SQL Commands SELECT * FROM employee; SELECT Name, Address FROM employee; SELECT * FROM employee WHERE EmployeeID = 1; SELECT * FROM employee WHERE Designation = ‘Developer’; [b] Query Records
  • 14. Saving Data into a Database SQLite in Android
  • 15. Saving Data into a Database Questions... Man who waits for roast duck to fly into mouth must wait very, very long time. -Chinese Proverb