SlideShare a Scribd company logo
1 of 19
Slide 1 of 19© People Strategists www.peoplestrategists.com
Data Storage in Android
Slide 2 of 19© People Strategists www.peoplestrategists.com Slide 2 of 57© People Strategists www.peoplestrategists.com
Data Storage in Android
 Preferences
 Files
 SQLite
 Network
Slide 3 of 19© People Strategists www.peoplestrategists.com Slide 3 of 57© People Strategists www.peoplestrategists.com
Slide 4 of 19© People Strategists www.peoplestrategists.com
Preference
A way of data persistence in Android that stores data in form of
key value pair like user specific setting, endpoint url, the
security access token etc.
Android stores shared preference settings
as XML file under:-
data/data/packagename/shared_prefs/
packagename_preferences.xml.
Slide 5 of 19© People Strategists www.peoplestrategists.com
Preference
once you uninstall the
application
once you clear
application data (through
Settings)
The data is lost when you perform any one following task:-
Slide 6 of 19© People Strategists www.peoplestrategists.com
Commonly used Shared Preferences
 ListPreference
 CheckBoxPreference
 EditTextPreference
Slide 7 of 19© People Strategists www.peoplestrategists.com
Preference
Creating preferences:-
The Preferences Activity screen is defined in the preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key=“pref_screen“….>
<CheckBoxPreference
android:key=“checkbox_pref“…. />
<ListPreference
android:key=“list_pref“…./>
<EditTextPreference
android:key=“edit_pref”…./>
</PreferenceScreen>
Slide 8 of 19© People Strategists www.peoplestrategists.com
Create the Preferences Activity
public class AppPreferences extends PreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref);
}
}
Preference
Slide 9 of 19© People Strategists www.peoplestrategists.com
Preference
To read the preferences values
SharedPreferences sp =
PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String strUserName = sp.getString("username", “ABC");
boolean bAppUpdates = sp.getBoolean("applicationUpdates",false);
String downloadType = sp.getString("downloadType","1");
Slide 10 of 19© People Strategists www.peoplestrategists.com Slide 10 of 57© People Strategists www.peoplestrategists.com
Slide 11 of 19© People Strategists www.peoplestrategists.com
Internal storage
 It is private to your application and other applications
cannot access them (nor can the user)
 When the app uninstalls, these files are removed.
External storage
 External storage such as SD card can also store application data.
 There's no security enforced upon files you save to the external
storage.
 All applications can read and write files placed on the external
storage and the user can remove them for this they need Read
and Write permission.
Internal & External
Storage
Slide 12 of 19© People Strategists www.peoplestrategists.com
SQLite DB
SQLite is an Open Source database which supports standard
relational database features like SQL syntax, transaction etc.
It is embedded into every Android
device.
Database is by default saved in the
directory
DATA/data/APP_NAME/databases/FILENA
ME.
Slide 13 of 19© People Strategists www.peoplestrategists.com
SQLite DB
Necessary classes for working with databases:-
 SQLiteHelper
 SQLiteDataBase
 Cursor
Slide 14 of 19© People Strategists www.peoplestrategists.com
Content Provider
Slide 15 of 19© People Strategists www.peoplestrategists.com Slide 15 of 57© People Strategists www.peoplestrategists.com
Content Provider
An Android component that supplies data from one app to another on
request.
A content provider can use different ways to store its data and the data can be
stored in a database, infiles, or even over a network.
Slide 16 of 19© People Strategists www.peoplestrategists.com Slide 16 of 57© People Strategists www.peoplestrategists.com
Content Provider
Slide 17 of 19© People Strategists www.peoplestrategists.com Slide 17 of 57© People Strategists www.peoplestrategists.com
Content Provider
Creating content provider
 Create a content provider class that extends the contentproviderbaseclass.
 Define your content provider uri address.
 Create your own database to keep the content.
 Implement content provider queries.
 Register your content provider in menifest file.
Slide 18 of 19© People Strategists www.peoplestrategists.com Slide 18 of 57© People Strategists www.peoplestrategists.com
Demo
Security and Packages
Slide 19 of 19© People Strategists www.peoplestrategists.com Slide 19 of 57© People Strategists www.peoplestrategists.com
Demo
Talking to the Server

More Related Content

Similar to Android - Day 2

Security Quick Tour
Security Quick TourSecurity Quick Tour
Security Quick Tour
Active Base
 
Chap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.pptChap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.ppt
LisaMalar
 
1. What are some risks, threats, and vulnerabilities commonly foun.docx
1. What are some risks, threats, and vulnerabilities commonly foun.docx1. What are some risks, threats, and vulnerabilities commonly foun.docx
1. What are some risks, threats, and vulnerabilities commonly foun.docx
elliotkimberlee
 

Similar to Android - Day 2 (20)

Securing Your Mobile Backend featuring Forrester Research inc - Combine API B...
Securing Your Mobile Backend featuring Forrester Research inc - Combine API B...Securing Your Mobile Backend featuring Forrester Research inc - Combine API B...
Securing Your Mobile Backend featuring Forrester Research inc - Combine API B...
 
Security Quick Tour
Security Quick TourSecurity Quick Tour
Security Quick Tour
 
Introduction to Big Data & Hadoop
Introduction to Big Data & Hadoop Introduction to Big Data & Hadoop
Introduction to Big Data & Hadoop
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Chap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.pptChap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.ppt
 
Android-data storage in android-chapter21
Android-data storage in android-chapter21Android-data storage in android-chapter21
Android-data storage in android-chapter21
 
Tk2323 lecture 7 data storage
Tk2323 lecture 7   data storageTk2323 lecture 7   data storage
Tk2323 lecture 7 data storage
 
DBMS Part1.pptx
DBMS Part1.pptxDBMS Part1.pptx
DBMS Part1.pptx
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
Informatica PowerCenter : Agile Data Integration Tool
Informatica PowerCenter : Agile Data Integration ToolInformatica PowerCenter : Agile Data Integration Tool
Informatica PowerCenter : Agile Data Integration Tool
 
Lesson02 database system architecture
Lesson02 database system architectureLesson02 database system architecture
Lesson02 database system architecture
 
SoftAge eDMS
SoftAge eDMSSoftAge eDMS
SoftAge eDMS
 
What's Next with Government Big Data
What's Next with Government Big Data What's Next with Government Big Data
What's Next with Government Big Data
 
Seqrite Data Loss Prevention- Complete Protection from Data Theft and Data Loss
Seqrite Data Loss Prevention- Complete Protection from Data Theft and Data LossSeqrite Data Loss Prevention- Complete Protection from Data Theft and Data Loss
Seqrite Data Loss Prevention- Complete Protection from Data Theft and Data Loss
 
1. What are some risks, threats, and vulnerabilities commonly foun.docx
1. What are some risks, threats, and vulnerabilities commonly foun.docx1. What are some risks, threats, and vulnerabilities commonly foun.docx
1. What are some risks, threats, and vulnerabilities commonly foun.docx
 
Informatica Capabilities As An ETL Tool
Informatica Capabilities As An ETL ToolInformatica Capabilities As An ETL Tool
Informatica Capabilities As An ETL Tool
 
A Backup and Restore Software for Android System
A Backup and Restore Software for Android SystemA Backup and Restore Software for Android System
A Backup and Restore Software for Android System
 
INT 1010 07-2.pdf
INT 1010 07-2.pdfINT 1010 07-2.pdf
INT 1010 07-2.pdf
 
Db2.security.slides
Db2.security.slidesDb2.security.slides
Db2.security.slides
 
IBM ProtecTIER Deduplication for Symantec OpenStorage
IBM ProtecTIER Deduplication for Symantec OpenStorageIBM ProtecTIER Deduplication for Symantec OpenStorage
IBM ProtecTIER Deduplication for Symantec OpenStorage
 

More from People Strategists (20)

Overview of web services
Overview of web servicesOverview of web services
Overview of web services
 
Spring Framework - III
Spring Framework - IIISpring Framework - III
Spring Framework - III
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Spring Framework -I
Spring Framework -ISpring Framework -I
Spring Framework -I
 
Hibernate II
Hibernate IIHibernate II
Hibernate II
 
Hibernate III
Hibernate IIIHibernate III
Hibernate III
 
Hibernate I
Hibernate IHibernate I
Hibernate I
 
Identifing Listeners and Filters
Identifing Listeners and FiltersIdentifing Listeners and Filters
Identifing Listeners and Filters
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 
Agile Dev. II
Agile Dev. IIAgile Dev. II
Agile Dev. II
 
Agile Dev. I
Agile Dev. IAgile Dev. I
Agile Dev. I
 
Working with Servlets
Working with ServletsWorking with Servlets
Working with Servlets
 
Overview of JEE Technology
Overview of JEE TechnologyOverview of JEE Technology
Overview of JEE Technology
 
JSP Technology II
JSP Technology IIJSP Technology II
JSP Technology II
 
XML Schemas
XML SchemasXML Schemas
XML Schemas
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Ajax and Jquery
Ajax and JqueryAjax and Jquery
Ajax and Jquery
 
CSS
CSSCSS
CSS
 
HTML/HTML5
HTML/HTML5HTML/HTML5
HTML/HTML5
 
JDBC
JDBCJDBC
JDBC
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Android - Day 2

  • 1. Slide 1 of 19© People Strategists www.peoplestrategists.com Data Storage in Android
  • 2. Slide 2 of 19© People Strategists www.peoplestrategists.com Slide 2 of 57© People Strategists www.peoplestrategists.com Data Storage in Android  Preferences  Files  SQLite  Network
  • 3. Slide 3 of 19© People Strategists www.peoplestrategists.com Slide 3 of 57© People Strategists www.peoplestrategists.com
  • 4. Slide 4 of 19© People Strategists www.peoplestrategists.com Preference A way of data persistence in Android that stores data in form of key value pair like user specific setting, endpoint url, the security access token etc. Android stores shared preference settings as XML file under:- data/data/packagename/shared_prefs/ packagename_preferences.xml.
  • 5. Slide 5 of 19© People Strategists www.peoplestrategists.com Preference once you uninstall the application once you clear application data (through Settings) The data is lost when you perform any one following task:-
  • 6. Slide 6 of 19© People Strategists www.peoplestrategists.com Commonly used Shared Preferences  ListPreference  CheckBoxPreference  EditTextPreference
  • 7. Slide 7 of 19© People Strategists www.peoplestrategists.com Preference Creating preferences:- The Preferences Activity screen is defined in the preferences.xml <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key=“pref_screen“….> <CheckBoxPreference android:key=“checkbox_pref“…. /> <ListPreference android:key=“list_pref“…./> <EditTextPreference android:key=“edit_pref”…./> </PreferenceScreen>
  • 8. Slide 8 of 19© People Strategists www.peoplestrategists.com Create the Preferences Activity public class AppPreferences extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref); } } Preference
  • 9. Slide 9 of 19© People Strategists www.peoplestrategists.com Preference To read the preferences values SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String strUserName = sp.getString("username", “ABC"); boolean bAppUpdates = sp.getBoolean("applicationUpdates",false); String downloadType = sp.getString("downloadType","1");
  • 10. Slide 10 of 19© People Strategists www.peoplestrategists.com Slide 10 of 57© People Strategists www.peoplestrategists.com
  • 11. Slide 11 of 19© People Strategists www.peoplestrategists.com Internal storage  It is private to your application and other applications cannot access them (nor can the user)  When the app uninstalls, these files are removed. External storage  External storage such as SD card can also store application data.  There's no security enforced upon files you save to the external storage.  All applications can read and write files placed on the external storage and the user can remove them for this they need Read and Write permission. Internal & External Storage
  • 12. Slide 12 of 19© People Strategists www.peoplestrategists.com SQLite DB SQLite is an Open Source database which supports standard relational database features like SQL syntax, transaction etc. It is embedded into every Android device. Database is by default saved in the directory DATA/data/APP_NAME/databases/FILENA ME.
  • 13. Slide 13 of 19© People Strategists www.peoplestrategists.com SQLite DB Necessary classes for working with databases:-  SQLiteHelper  SQLiteDataBase  Cursor
  • 14. Slide 14 of 19© People Strategists www.peoplestrategists.com Content Provider
  • 15. Slide 15 of 19© People Strategists www.peoplestrategists.com Slide 15 of 57© People Strategists www.peoplestrategists.com Content Provider An Android component that supplies data from one app to another on request. A content provider can use different ways to store its data and the data can be stored in a database, infiles, or even over a network.
  • 16. Slide 16 of 19© People Strategists www.peoplestrategists.com Slide 16 of 57© People Strategists www.peoplestrategists.com Content Provider
  • 17. Slide 17 of 19© People Strategists www.peoplestrategists.com Slide 17 of 57© People Strategists www.peoplestrategists.com Content Provider Creating content provider  Create a content provider class that extends the contentproviderbaseclass.  Define your content provider uri address.  Create your own database to keep the content.  Implement content provider queries.  Register your content provider in menifest file.
  • 18. Slide 18 of 19© People Strategists www.peoplestrategists.com Slide 18 of 57© People Strategists www.peoplestrategists.com Demo Security and Packages
  • 19. Slide 19 of 19© People Strategists www.peoplestrategists.com Slide 19 of 57© People Strategists www.peoplestrategists.com Demo Talking to the Server