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

Pillars of Heterogeneous HDFS Storage
Pillars of Heterogeneous HDFS StoragePillars of Heterogeneous HDFS Storage
Pillars of Heterogeneous HDFS Storage
Pete Kisich
 
Big file tablespaces
Big file tablespacesBig file tablespaces
Big file tablespaces
dev3993
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
Enoch Joshua
 
Hadoop distributed file system
Hadoop distributed file systemHadoop distributed file system
Hadoop distributed file system
Ameya Vijay Gokhale
 
iOS: Using persistant storage
iOS: Using persistant storageiOS: Using persistant storage
iOS: Using persistant storageJussi Pohjolainen
 
Sql Health in a SharePoint environment
Sql Health in a SharePoint environmentSql Health in a SharePoint environment
Sql Health in a SharePoint environment
Enrique Lima
 
MongoDB-SESION01
MongoDB-SESION01MongoDB-SESION01
MongoDB-SESION01
Jainul Musani
 
Redis database
Redis databaseRedis database
Redis database
Ñáwrás Ñzár
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
Rohit Bishnoi
 
Connecting to my sql using PHP
Connecting to my sql using PHPConnecting to my sql using PHP
Connecting to my sql using PHP
Nisa Soomro
 
Android Level 2
Android Level 2Android Level 2
Android Level 2
DevMix
 
SSDs - Improving Performance of Storage Arrays
SSDs - Improving Performance of Storage ArraysSSDs - Improving Performance of Storage Arrays
SSDs - Improving Performance of Storage Arrays
nomathjobs
 
Accesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformAccesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data Platform
Luca Di Fino
 
Intro To Couch Db
Intro To Couch DbIntro To Couch Db
Intro To Couch Db
Shahar Evron
 
Hadoop introduction seminar presentation
Hadoop introduction seminar presentationHadoop introduction seminar presentation
Hadoop introduction seminar presentation
puneet yadav
 
MongoDB-SESSION02
MongoDB-SESSION02MongoDB-SESSION02
MongoDB-SESSION02
Jainul Musani
 
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
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
How Clean is your database? Data scrubbing for all skills setsHow Clean is your database? Data scrubbing for all skills sets
How Clean is your database? Data scrubbing for all skills sets
Chad Petrovay
 
Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
Enoch Joshua
 
Mongo DB for Java, Python and PHP Developers
Mongo DB for Java, Python and PHP DevelopersMongo DB for Java, Python and PHP Developers
Mongo DB for Java, Python and PHP Developers
Rick Hightower
 

What's hot (20)

Pillars of Heterogeneous HDFS Storage
Pillars of Heterogeneous HDFS StoragePillars of Heterogeneous HDFS Storage
Pillars of Heterogeneous HDFS Storage
 
Big file tablespaces
Big file tablespacesBig file tablespaces
Big file tablespaces
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
 
Hadoop distributed file system
Hadoop distributed file systemHadoop distributed file system
Hadoop distributed file system
 
iOS: Using persistant storage
iOS: Using persistant storageiOS: Using persistant storage
iOS: Using persistant storage
 
Sql Health in a SharePoint environment
Sql Health in a SharePoint environmentSql Health in a SharePoint environment
Sql Health in a SharePoint environment
 
MongoDB-SESION01
MongoDB-SESION01MongoDB-SESION01
MongoDB-SESION01
 
Redis database
Redis databaseRedis database
Redis database
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Connecting to my sql using PHP
Connecting to my sql using PHPConnecting to my sql using PHP
Connecting to my sql using PHP
 
Android Level 2
Android Level 2Android Level 2
Android Level 2
 
SSDs - Improving Performance of Storage Arrays
SSDs - Improving Performance of Storage ArraysSSDs - Improving Performance of Storage Arrays
SSDs - Improving Performance of Storage Arrays
 
Accesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformAccesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data Platform
 
Intro To Couch Db
Intro To Couch DbIntro To Couch Db
Intro To Couch Db
 
Hadoop introduction seminar presentation
Hadoop introduction seminar presentationHadoop introduction seminar presentation
Hadoop introduction seminar presentation
 
MongoDB-SESSION02
MongoDB-SESSION02MongoDB-SESSION02
MongoDB-SESSION02
 
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
Reduce Storage Costs by 5x Using The New HDFS Tiered Storage Feature
 
How Clean is your database? Data scrubbing for all skills sets
How Clean is your database? Data scrubbing for all skills setsHow Clean is your database? Data scrubbing for all skills sets
How Clean is your database? Data scrubbing for all skills sets
 
Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
 
Mongo DB for Java, Python and PHP Developers
Mongo DB for Java, Python and PHP DevelopersMongo DB for Java, Python and PHP Developers
Mongo DB for Java, Python and PHP Developers
 

Viewers also liked

Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2
Ahsanul Karim
 
Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Day 2 android internals a quick overview
Day 2 android internals a quick overviewDay 2 android internals a quick overview
Day 2 android internals a quick overviewAhsanul Karim
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesAhsanul Karim
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
Parinita03
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting Started
Ahsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedAhsanul Karim
 
Android before getting started
Android before getting startedAndroid before getting started
Android before getting startedAhsanul Karim
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)Ahsanul Karim
 
Lecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewLecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewAhsanul Karim
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIAhsanul Karim
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerAhsanul Karim
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 

Viewers also liked (20)

Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2
 
Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
 
List Views
List ViewsList Views
List Views
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Day 2 android internals a quick overview
Day 2 android internals a quick overviewDay 2 android internals a quick overview
Day 2 android internals a quick overview
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver Component
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting Started
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting Started
 
Client-Server
Client-ServerClient-Server
Client-Server
 
Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
 
Lecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewLecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick Overview
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation Primer
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 

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

android sqlite
android sqliteandroid sqlite
android sqliteDeepa Rani
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
AYESHA JAVED
 
Mysql database
Mysql databaseMysql database
Mysql database
Arshikhan08
 
Tasks of dba
Tasks of dbaTasks of dba
Tasks of dba
Attia Qamar
 
Tasks of database administrator
Tasks of database administratorTasks of database administrator
Tasks of database administratorAttia Qamar
 
Sq lite
Sq liteSq lite
Sq lite
vinoth raj
 
my sql
my sqlmy sql
my sql
Ayush Pandey
 
What is new in MariaDB 10.6?
What is new in MariaDB 10.6?What is new in MariaDB 10.6?
What is new in MariaDB 10.6?
Mydbops
 
Class viii ch-2 log on to access
Class  viii ch-2 log on to accessClass  viii ch-2 log on to access
Class viii ch-2 log on to access
jessandy
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big Data
Gruter
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
Dilfaroz Khan
 
Sql in dbms
Sql in dbmsSql in dbms
Sql in dbms
Arafat Hossan
 
Introducing ms sql_server
Introducing ms sql_serverIntroducing ms sql_server
Introducing ms sql_serverleetinhf
 
20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell
Ivan Ma
 
ora_sothea
ora_sotheaora_sothea
ora_sothea
thysothea
 
Sqllite
SqlliteSqllite
Sqllite
Senthil Kumar
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian Malbeuf
CTE Solutions Inc.
 
Get started with Microsoft SQL Polybase
Get started with Microsoft SQL PolybaseGet started with Microsoft SQL Polybase
Get started with Microsoft SQL PolybaseHenk van der Valk
 
Future Roadmap for Windows Server 2012 R2, System Center 2012 R2 and Azure
Future Roadmap for Windows Server 2012 R2, System Center 2012 R2 and AzureFuture Roadmap for Windows Server 2012 R2, System Center 2012 R2 and Azure
Future Roadmap for Windows Server 2012 R2, System Center 2012 R2 and Azure
Digicomp Academy AG
 

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

android sqlite
android sqliteandroid sqlite
android sqlite
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
 
Mysql database
Mysql databaseMysql database
Mysql database
 
Tasks of dba
Tasks of dbaTasks of dba
Tasks of dba
 
Tasks of database administrator
Tasks of database administratorTasks of database administrator
Tasks of database administrator
 
Sq lite
Sq liteSq lite
Sq lite
 
my sql
my sqlmy sql
my sql
 
What is new in MariaDB 10.6?
What is new in MariaDB 10.6?What is new in MariaDB 10.6?
What is new in MariaDB 10.6?
 
Class viii ch-2 log on to access
Class  viii ch-2 log on to accessClass  viii ch-2 log on to access
Class viii ch-2 log on to access
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big Data
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
Sql in dbms
Sql in dbmsSql in dbms
Sql in dbms
 
Chap09
Chap09Chap09
Chap09
 
Introducing ms sql_server
Introducing ms sql_serverIntroducing ms sql_server
Introducing ms sql_server
 
20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell
 
ora_sothea
ora_sotheaora_sothea
ora_sothea
 
Sqllite
SqlliteSqllite
Sqllite
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian Malbeuf
 
Get started with Microsoft SQL Polybase
Get started with Microsoft SQL PolybaseGet started with Microsoft SQL Polybase
Get started with Microsoft SQL Polybase
 
Future Roadmap for Windows Server 2012 R2, System Center 2012 R2 and Azure
Future Roadmap for Windows Server 2012 R2, System Center 2012 R2 and AzureFuture Roadmap for Windows Server 2012 R2, System Center 2012 R2 and Azure
Future Roadmap for Windows Server 2012 R2, System Center 2012 R2 and Azure
 

More from Ahsanul Karim

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

More from Ahsanul Karim (14)

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

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 

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

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