SlideShare a Scribd company logo
1 of 53
Download to read offline
SharedPreferences
Internal Storage
External Storage
SQLite databases
Small amounts of primitive data
Small to medium amounts of private
data
Larger amounts of non-private data
Store small to large amounts of
private, structured data
A persistent map
Holds key-value pairs of simple data
types
Automatically persisted across
application sessions
Often used for long-term storage of
customizable application data
Account name
Favorite WiFi networks
User customizations
To get a SharedPreference object
associated with a given Activity
Activity.getPreferences (int mode)
MODE_PRIVATE
Context.getSharedPreferences ("

 
 
String name, int mode)
name – name of SharedPreferences file
Mode – MODE_PRIVATE
Call SharedPreferences.edit()
Returns a SharedPreferences.Editor
instance
Add values to SharedPreferences using
SharedPreferences.Editor instance
putInt(String key, int value)
putString(String key, String value)
remove(String key)
Commit edited values with 
SharedPreferences.Editor.commit()
Use SharedPreferences methods to read
values
getAll()
getBoolean(String key, …) 
getString(String key, …)
When the user presses the play button,
the application displays a random
number
The application keeps track of the
highest number seen so far
A Class that supports displaying &
modifying user preferences
This application displays a
PreferenceFragment, which allows the
user to enter and change a persistent
user name
Class represents a file system entity
identified by a pathname
Storage areas are classified as
internal or external
Internal memory usually used for
smaller, application private data sets
External memory usually used for
larger, non-private data sets
FileOutputStream
openFileOutput (String name, int mode)
Open private file for writing. Creates the
file if it doesn't already exist
FileInputStream
openFileInput (String name)
Open private file for reading
Many others. See documentation.
If a text file does not already exist,
application writes text to that text file
Application then reads data from the
text file and displays it
Removable media may appear/disappear
without warning
String Environment.
 
 
 
 

 
 
getExternalStorageState()
MEDIA_MOUNTED - present & mounted
with read/write access
MEDIA_MOUNTED_READ_ONLY - present
& mounted with read-only access
MEDIA_REMOVED - not present
Etc.
Permission to write external files
<uses-permission android:name= "
“android.permission."

WRITE_EXTERNAL_STORAGE" />
Application reads an image file from
the resources directory
Copies that file to external storage
Reads image data from the file in
external storage
then displays the image
Temporary files that may be deleted by
the system when storage is low
Files removed when application
uninstalled
File Context.getCacheDir()
Returns absolute path to an
application-specific directory that can
be used for temporary files
Context.getExternalCacheDir() 
returns a File representing external
storage directory for cache files
SQLite provides in-memory database
Designed to operate within a very small
footprint (<300kB)
Implements most of SQL92
Supports ACID transactions
Atomic, Consistent, Isolated & Durable
Recommended method relies on a helper
class called SQLiteOpenHelper
Subclass SQLiteOpenHelper
Call super() from subclass
constructor to initialize underlying
database
Override onCreate() 
Override onUpgrade()
Execute CREATE TABLE commands
Use SQLiteOpenHelper methods to
open & return underlying database
Execute operations on underlying
database
Application creates an SQLite database
and inserts records, some with errors,
into it
When user presses the Fix button, the
application deletes, updates and
redisplays the corrected database
records
Databases stored in
/data/data/<package name>/databases/
Can examine database with sqlite3
# adb -s emulator-5554 shell
# sqlite3 /data/data/
course.examples.DataManagement.Data
BaseExample/databases/artist_dbd
ContentProvider

More Related Content

What's hot

Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorialinfo_zybotech
 
Design of file system architecture with cluster
Design of file system architecture with clusterDesign of file system architecture with cluster
Design of file system architecture with clustereSAT Publishing House
 
Sensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data PublishingSensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data PublishingJAYAPRAKASH JPINFOTECH
 
Sensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data PublishingSensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data PublishingJAYAPRAKASH JPINFOTECH
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android ApplicationMark Lester Navarro
 
Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0LiquidHub
 
Clustering of medline documents using semi supervised spectral clustering
Clustering of medline documents using semi supervised spectral clusteringClustering of medline documents using semi supervised spectral clustering
Clustering of medline documents using semi supervised spectral clusteringeSAT Publishing House
 

What's hot (10)

ado.net
ado.netado.net
ado.net
 
Android Database
Android DatabaseAndroid Database
Android Database
 
Android database tutorial
Android database tutorialAndroid database tutorial
Android database tutorial
 
Design of file system architecture with cluster
Design of file system architecture with clusterDesign of file system architecture with cluster
Design of file system architecture with cluster
 
Sensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data PublishingSensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data Publishing
 
Ado.net
Ado.netAdo.net
Ado.net
 
Sensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data PublishingSensitive Label Privacy Preservation with Anatomization for Data Publishing
Sensitive Label Privacy Preservation with Anatomization for Data Publishing
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
 
Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0
 
Clustering of medline documents using semi supervised spectral clustering
Clustering of medline documents using semi supervised spectral clusteringClustering of medline documents using semi supervised spectral clustering
Clustering of medline documents using semi supervised spectral clustering
 

Similar to SharedPreferences, Internal & External Storage, SQLite Databases

Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android Aakash Ugale
 
Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Khaled Anaqwa
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorageKrazy Koder
 
Android App Development - 09 Storage
Android App Development - 09 StorageAndroid App Development - 09 Storage
Android App Development - 09 StorageDiego Grancini
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfAbdullahMunir32
 
03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)TECOS
 
Persistence on iOS
Persistence on iOSPersistence on iOS
Persistence on iOSMake School
 
12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptxFaezNasir
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT TalkConstantine Mars
 
Architecture Components
Architecture Components Architecture Components
Architecture Components DataArt
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WPNguyen Tuan
 
Techniques for Cross Platform .NET Development
Techniques for Cross Platform .NET DevelopmentTechniques for Cross Platform .NET Development
Techniques for Cross Platform .NET DevelopmentJeremy Hutchinson
 

Similar to SharedPreferences, Internal & External Storage, SQLite Databases (20)

Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
 
Android - Saving data
Android - Saving dataAndroid - Saving data
Android - Saving data
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 
Android Data Storagefinal
Android Data StoragefinalAndroid Data Storagefinal
Android Data Storagefinal
 
Android App Development - 09 Storage
Android App Development - 09 StorageAndroid App Development - 09 Storage
Android App Development - 09 Storage
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
 
03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)
 
Persistence on iOS
Persistence on iOSPersistence on iOS
Persistence on iOS
 
12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx
 
Level 4
Level 4Level 4
Level 4
 
Application Hosting
Application HostingApplication Hosting
Application Hosting
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT Talk
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 
6.C#
6.C# 6.C#
6.C#
 
Memory management
Memory managementMemory management
Memory management
 
Hadoop HDFS Concepts
Hadoop HDFS ConceptsHadoop HDFS Concepts
Hadoop HDFS Concepts
 
Techniques for Cross Platform .NET Development
Techniques for Cross Platform .NET DevelopmentTechniques for Cross Platform .NET Development
Techniques for Cross Platform .NET Development
 

More from Madrasah Idrisiah

DSKP Sains Komputer Tingkatan 5 (KSSM)
DSKP Sains Komputer Tingkatan 5 (KSSM)DSKP Sains Komputer Tingkatan 5 (KSSM)
DSKP Sains Komputer Tingkatan 5 (KSSM)Madrasah Idrisiah
 
Nota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEINota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEIMadrasah Idrisiah
 
Nota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEINota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEIMadrasah Idrisiah
 
SAINS KOMPUTER - AMALAN TERBAIK PENGATURCARAAN
SAINS KOMPUTER  - AMALAN TERBAIK PENGATURCARAANSAINS KOMPUTER  - AMALAN TERBAIK PENGATURCARAAN
SAINS KOMPUTER - AMALAN TERBAIK PENGATURCARAANMadrasah Idrisiah
 
Sains komputer : struktur kawalan
Sains komputer : struktur kawalanSains komputer : struktur kawalan
Sains komputer : struktur kawalanMadrasah Idrisiah
 
Jawapan latihan : TMK PLUG TAHUN 6 2015
Jawapan latihan : TMK PLUG TAHUN 6 2015Jawapan latihan : TMK PLUG TAHUN 6 2015
Jawapan latihan : TMK PLUG TAHUN 6 2015Madrasah Idrisiah
 

More from Madrasah Idrisiah (8)

DSKP Sains Komputer Tingkatan 5 (KSSM)
DSKP Sains Komputer Tingkatan 5 (KSSM)DSKP Sains Komputer Tingkatan 5 (KSSM)
DSKP Sains Komputer Tingkatan 5 (KSSM)
 
Nota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEINota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 5 lengkap - SUBJEK MPEI
 
Nota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEINota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEI
Nota Subjek Sains Komputer Tingkatan 4 lengkap - SUBJEK MPEI
 
SAINS KOMPUTER - AMALAN TERBAIK PENGATURCARAAN
SAINS KOMPUTER  - AMALAN TERBAIK PENGATURCARAANSAINS KOMPUTER  - AMALAN TERBAIK PENGATURCARAAN
SAINS KOMPUTER - AMALAN TERBAIK PENGATURCARAAN
 
Sains komputer : struktur kawalan
Sains komputer : struktur kawalanSains komputer : struktur kawalan
Sains komputer : struktur kawalan
 
Jawapan latihan : TMK PLUG TAHUN 6 2015
Jawapan latihan : TMK PLUG TAHUN 6 2015Jawapan latihan : TMK PLUG TAHUN 6 2015
Jawapan latihan : TMK PLUG TAHUN 6 2015
 
Jawapan latihan
Jawapan latihanJawapan latihan
Jawapan latihan
 
Blog Tutorial
Blog TutorialBlog Tutorial
Blog Tutorial
 

SharedPreferences, Internal & External Storage, SQLite Databases