SlideShare a Scribd company logo
1 of 22
Download to read offline
Android Local
Databases
By Muzamil Nawaz
Data Storage
on Android
• Androidprovides several optionsfor you to save
your app data.
• The solutionyou choose dependson your specific
needs, such as how much space your datarequires,
what kind of data you need to store.
• Different data storage optionsavailableon
Android:
Internal file storage:Store app-privatefiles on the
device file system.
External file storage: Store files on the shared external
file system. Thisis usuallyfor shared user files,
such as photos.
Shared preferences: Store privateprimitive data in key-
value pairs.
Databases : Store structured datain a private
database.
• Except for some types of files on external storage,
all these optionsare intended for app-privatedata,
the data is not naturallyaccessible to other apps.
Why SqLite?
SQLite Database for Data Storage and Retrieval
SQLite is very lightweight, open source, relational database that comes with Android OS.
In Android, integrating SQLite is a tedious task as it needs writing lot of boilerplate code
to store simple data.
Consider SQLite when your app needs to store simple and structured data objects.
Alternatively, Room Persistence Library could be used for better APIs and easier
integration.
SQLite
Challenges
Boilerplate code to convert
SQL queriestoJavaData
objects
Database operationsonthe
main thread
Unmaintainable code - As your
schemachangesyouneedto
update the affectedSQL
queriesmanually.
SQL queriescheckedat
runtime (Nocompile time
verificationof SQLqueries)
Untestable code
Room
Persistence
Library (RPL)
Solution for the
above
challenges
Room Persistence Library (RPL)
• Room is an abstraction on top of SQLite database. It's part of the
Architecture Components by Google.
• Room enables you to easily work SQLite databases in Android.
• The Room persistence library acts as a layer that abstracts raw SQLite
and lets you make use of robust database access while keep you close to
SQLite so it doesn't get in the way when you want to access low level
features of SQLite.
Components of Room Library
Components of Room
Library
There are 3 major components in Room:
• Database : Contains the database holder and
serves as the main access point for the underlying
connection to your app's persisted, relational data.
• Entity: Represents a table within the database.
• DAO: Contains the methods used for accessing the
database.
Working of RPL
Steps for making an app that uses
SQLite Database to store data
• Add Dependencies
• Add Room Entities
• Add DAO Class
• Build Database
Important Note
to remember
Add Dependecies
• Open the application level build.gradle file and add
the dependencies for Room:
Implementation "android.arch.persistence.room:runt
ime:1.1.0"
AnnotationProcessor "android.arch.persistence.room
:compiler:1.1.0"
testImplementation "android.arch.persistence.room:
testing:1.1.0"
Adding Room Entities
Important
annotations
• @Entity – by using this annotation, Room
will know that this class will be a table in the
database and the table name will define the
name of the table
• @PrimaryKey – is used to set up the primary
key of the table.
• @ColumnInfo – defines the name of the
column from the table if we don’t want to
use the name of that field
• You also need to add getters and setters.
Creating DAO Class
Details about DAO
• @Dao – by using this annotation Room knows that it should provide
the implementation for our interface by generating code for the
defined methods.
• In this interface we could define the CRUD operations for our entity and
also any other operations that are necessary in order to obtain the data.
• Also Room offers us query validation at compilation time, so if we will
write incorrectly the name of a table or a field we will know if after the
code will be compiled.
Database Class
Database Class contd...
Got Any
Questions?
Please go ahead...

More Related Content

What's hot

SAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsSAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsKiran Joy
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.netPaneliya Prince
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionarySmartGokul4
 
4 Ways to Merge IBM i Data with Microsoft Excel
4 Ways to Merge IBM i Data with Microsoft Excel4 Ways to Merge IBM i Data with Microsoft Excel
4 Ways to Merge IBM i Data with Microsoft ExcelHelpSystems
 
Actuate BIRT - library
Actuate BIRT -  libraryActuate BIRT -  library
Actuate BIRT - libraryAishwarya Savant
 
Ms access 1
Ms access 1Ms access 1
Ms access 1aliamla
 
Instant J Chem - Introduction and latest
Instant J Chem - Introduction and latestInstant J Chem - Introduction and latest
Instant J Chem - Introduction and latestChemAxon
 
Using sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsUsing sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsVincent Clyde
 
Flexible Resources In 3 6 And E4
Flexible Resources In 3 6 And E4Flexible Resources In 3 6 And E4
Flexible Resources In 3 6 And E4szbra
 
Oracle reports
Oracle reportsOracle reports
Oracle reportsLacc Corona
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1Techglyphs
 
Access essentials brionna elmore
Access essentials brionna elmoreAccess essentials brionna elmore
Access essentials brionna elmorecapjjj
 
ACS 248th Paper 108 NIST-IUPAC Solubility Data
ACS 248th Paper 108 NIST-IUPAC Solubility DataACS 248th Paper 108 NIST-IUPAC Solubility Data
ACS 248th Paper 108 NIST-IUPAC Solubility DataStuart Chalk
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in androidGourav Kumar Saini
 
Introduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the WorldIntroduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the Worldjkreibich
 
External Content Types WIS SPUG
External Content Types  WIS SPUGExternal Content Types  WIS SPUG
External Content Types WIS SPUGarenza
 
1-informatica-training
1-informatica-training1-informatica-training
1-informatica-trainingKrishna Sujeer
 
Database application and design
Database application and designDatabase application and design
Database application and designsieedah
 

What's hot (20)

SAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsSAP BO Web Intelligence Basics
SAP BO Web Intelligence Basics
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionary
 
4 Ways to Merge IBM i Data with Microsoft Excel
4 Ways to Merge IBM i Data with Microsoft Excel4 Ways to Merge IBM i Data with Microsoft Excel
4 Ways to Merge IBM i Data with Microsoft Excel
 
Actuate BIRT - library
Actuate BIRT -  libraryActuate BIRT -  library
Actuate BIRT - library
 
Ms access 1
Ms access 1Ms access 1
Ms access 1
 
Instant J Chem - Introduction and latest
Instant J Chem - Introduction and latestInstant J Chem - Introduction and latest
Instant J Chem - Introduction and latest
 
Using sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsUsing sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add ons
 
Flexible Resources In 3 6 And E4
Flexible Resources In 3 6 And E4Flexible Resources In 3 6 And E4
Flexible Resources In 3 6 And E4
 
Oracle reports
Oracle reportsOracle reports
Oracle reports
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1
 
Access essentials brionna elmore
Access essentials brionna elmoreAccess essentials brionna elmore
Access essentials brionna elmore
 
ACS 248th Paper 108 NIST-IUPAC Solubility Data
ACS 248th Paper 108 NIST-IUPAC Solubility DataACS 248th Paper 108 NIST-IUPAC Solubility Data
ACS 248th Paper 108 NIST-IUPAC Solubility Data
 
Abap dictionary 1
Abap dictionary 1Abap dictionary 1
Abap dictionary 1
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Introduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the WorldIntroduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the World
 
External Content Types WIS SPUG
External Content Types  WIS SPUGExternal Content Types  WIS SPUG
External Content Types WIS SPUG
 
1-informatica-training
1-informatica-training1-informatica-training
1-informatica-training
 
Database application and design
Database application and designDatabase application and design
Database application and design
 
App c classicadmin2
App c classicadmin2App c classicadmin2
App c classicadmin2
 

Similar to SQLite Database for Structured Data Storage on Android

Android development beyond the basics
Android development   beyond the basicsAndroid development   beyond the basics
Android development beyond the basicsVanjikumaran Sivajothy
 
Android project architecture
Android project architectureAndroid project architecture
Android project architectureSourabh Sahu
 
iOS Beginners Lesson 3
iOS Beginners Lesson 3iOS Beginners Lesson 3
iOS Beginners Lesson 3Calvin Cheng
 
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...DicodingEvent
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorageKrazy Koder
 
D I T211 Chapter 1
D I T211    Chapter 1D I T211    Chapter 1
D I T211 Chapter 1askme
 
D I T211 Chapter 1 1
D I T211    Chapter 1 1D I T211    Chapter 1 1
D I T211 Chapter 1 1askme
 
Overview of Data Base Systems Concepts and Architecture
Overview of Data Base Systems Concepts and ArchitectureOverview of Data Base Systems Concepts and Architecture
Overview of Data Base Systems Concepts and ArchitectureRubal Sagwal
 
The Best Local Database for React Native Application Development .pdf
The Best Local Database for React Native Application Development .pdfThe Best Local Database for React Native Application Development .pdf
The Best Local Database for React Native Application Development .pdfTechugo
 
Android session 4-behestee
Android session 4-behesteeAndroid session 4-behestee
Android session 4-behesteeHussain Behestee
 
Lecture-1.ppt
Lecture-1.pptLecture-1.ppt
Lecture-1.pptChSheraz3
 
dbms introduction.pptx
dbms introduction.pptxdbms introduction.pptx
dbms introduction.pptxATISHAYJAIN847270
 
12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptxFaezNasir
 
Shaping the Role of a Data Lake in a Modern Data Fabric Architecture
Shaping the Role of a Data Lake in a Modern Data Fabric ArchitectureShaping the Role of a Data Lake in a Modern Data Fabric Architecture
Shaping the Role of a Data Lake in a Modern Data Fabric ArchitectureDenodo
 
(BDT313) Amazon DynamoDB For Big Data
(BDT313) Amazon DynamoDB For Big Data(BDT313) Amazon DynamoDB For Big Data
(BDT313) Amazon DynamoDB For Big DataAmazon Web Services
 

Similar to SQLite Database for Structured Data Storage on Android (20)

Android development beyond the basics
Android development   beyond the basicsAndroid development   beyond the basics
Android development beyond the basics
 
Asp .net folders and web.config
Asp .net folders and web.configAsp .net folders and web.config
Asp .net folders and web.config
 
Storage 8
Storage   8Storage   8
Storage 8
 
Android project architecture
Android project architectureAndroid project architecture
Android project architecture
 
Asp .net folders and web.config
Asp .net folders and web.configAsp .net folders and web.config
Asp .net folders and web.config
 
Asp folders and web configurations
Asp folders and web configurationsAsp folders and web configurations
Asp folders and web configurations
 
iOS Beginners Lesson 3
iOS Beginners Lesson 3iOS Beginners Lesson 3
iOS Beginners Lesson 3
 
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 
D I T211 Chapter 1
D I T211    Chapter 1D I T211    Chapter 1
D I T211 Chapter 1
 
D I T211 Chapter 1 1
D I T211    Chapter 1 1D I T211    Chapter 1 1
D I T211 Chapter 1 1
 
Overview of Data Base Systems Concepts and Architecture
Overview of Data Base Systems Concepts and ArchitectureOverview of Data Base Systems Concepts and Architecture
Overview of Data Base Systems Concepts and Architecture
 
The Best Local Database for React Native Application Development .pdf
The Best Local Database for React Native Application Development .pdfThe Best Local Database for React Native Application Development .pdf
The Best Local Database for React Native Application Development .pdf
 
Android session 4-behestee
Android session 4-behesteeAndroid session 4-behestee
Android session 4-behestee
 
DBMS Bascis
DBMS BascisDBMS Bascis
DBMS Bascis
 
Lecture-1.ppt
Lecture-1.pptLecture-1.ppt
Lecture-1.ppt
 
dbms introduction.pptx
dbms introduction.pptxdbms introduction.pptx
dbms introduction.pptx
 
12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx
 
Shaping the Role of a Data Lake in a Modern Data Fabric Architecture
Shaping the Role of a Data Lake in a Modern Data Fabric ArchitectureShaping the Role of a Data Lake in a Modern Data Fabric Architecture
Shaping the Role of a Data Lake in a Modern Data Fabric Architecture
 
(BDT313) Amazon DynamoDB For Big Data
(BDT313) Amazon DynamoDB For Big Data(BDT313) Amazon DynamoDB For Big Data
(BDT313) Amazon DynamoDB For Big Data
 

More from FatimaYousif11

Day 2 react bootcamp
Day 2 react bootcampDay 2 react bootcamp
Day 2 react bootcampFatimaYousif11
 
The concept of vector art
The concept of vector artThe concept of vector art
The concept of vector artFatimaYousif11
 
CV/resume writing
CV/resume writingCV/resume writing
CV/resume writingFatimaYousif11
 
Day 8 sketchware
Day 8  sketchwareDay 8  sketchware
Day 8 sketchwareFatimaYousif11
 
Day 5 android app code advancement
Day 5  android app code advancementDay 5  android app code advancement
Day 5 android app code advancementFatimaYousif11
 
Day 4 android bootcamp
Day 4  android bootcampDay 4  android bootcamp
Day 4 android bootcampFatimaYousif11
 
Android app code mediator
Android app code mediatorAndroid app code mediator
Android app code mediatorFatimaYousif11
 
Android App code starter
Android App code starterAndroid App code starter
Android App code starterFatimaYousif11
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1FatimaYousif11
 
Getting started with android development
Getting started with android developmentGetting started with android development
Getting started with android developmentFatimaYousif11
 
Hacktoberfest slides
Hacktoberfest slidesHacktoberfest slides
Hacktoberfest slidesFatimaYousif11
 
Info session about dsc
Info session  about dscInfo session  about dsc
Info session about dscFatimaYousif11
 

More from FatimaYousif11 (15)

Day 2 react bootcamp
Day 2 react bootcampDay 2 react bootcamp
Day 2 react bootcamp
 
The concept of vector art
The concept of vector artThe concept of vector art
The concept of vector art
 
CV/resume writing
CV/resume writingCV/resume writing
CV/resume writing
 
Day 8 sketchware
Day 8  sketchwareDay 8  sketchware
Day 8 sketchware
 
Firebase
Firebase Firebase
Firebase
 
Day 5 android app code advancement
Day 5  android app code advancementDay 5  android app code advancement
Day 5 android app code advancement
 
Day 4 android bootcamp
Day 4  android bootcampDay 4  android bootcamp
Day 4 android bootcamp
 
Android app code mediator
Android app code mediatorAndroid app code mediator
Android app code mediator
 
Android App code starter
Android App code starterAndroid App code starter
Android App code starter
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1
 
Getting started with android development
Getting started with android developmentGetting started with android development
Getting started with android development
 
Oop
OopOop
Oop
 
Hello to Kotlin
Hello to KotlinHello to Kotlin
Hello to Kotlin
 
Hacktoberfest slides
Hacktoberfest slidesHacktoberfest slides
Hacktoberfest slides
 
Info session about dsc
Info session  about dscInfo session  about dsc
Info session about dsc
 

Recently uploaded

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 

SQLite Database for Structured Data Storage on Android

  • 2. Data Storage on Android • Androidprovides several optionsfor you to save your app data. • The solutionyou choose dependson your specific needs, such as how much space your datarequires, what kind of data you need to store. • Different data storage optionsavailableon Android: Internal file storage:Store app-privatefiles on the device file system. External file storage: Store files on the shared external file system. Thisis usuallyfor shared user files, such as photos. Shared preferences: Store privateprimitive data in key- value pairs. Databases : Store structured datain a private database. • Except for some types of files on external storage, all these optionsare intended for app-privatedata, the data is not naturallyaccessible to other apps.
  • 4. SQLite Database for Data Storage and Retrieval SQLite is very lightweight, open source, relational database that comes with Android OS. In Android, integrating SQLite is a tedious task as it needs writing lot of boilerplate code to store simple data. Consider SQLite when your app needs to store simple and structured data objects. Alternatively, Room Persistence Library could be used for better APIs and easier integration.
  • 5. SQLite Challenges Boilerplate code to convert SQL queriestoJavaData objects Database operationsonthe main thread Unmaintainable code - As your schemachangesyouneedto update the affectedSQL queriesmanually. SQL queriescheckedat runtime (Nocompile time verificationof SQLqueries) Untestable code
  • 7. Room Persistence Library (RPL) • Room is an abstraction on top of SQLite database. It's part of the Architecture Components by Google. • Room enables you to easily work SQLite databases in Android. • The Room persistence library acts as a layer that abstracts raw SQLite and lets you make use of robust database access while keep you close to SQLite so it doesn't get in the way when you want to access low level features of SQLite.
  • 9. Components of Room Library There are 3 major components in Room: • Database : Contains the database holder and serves as the main access point for the underlying connection to your app's persisted, relational data. • Entity: Represents a table within the database. • DAO: Contains the methods used for accessing the database.
  • 11. Steps for making an app that uses SQLite Database to store data • Add Dependencies • Add Room Entities • Add DAO Class • Build Database
  • 13. Add Dependecies • Open the application level build.gradle file and add the dependencies for Room: Implementation "android.arch.persistence.room:runt ime:1.1.0" AnnotationProcessor "android.arch.persistence.room :compiler:1.1.0" testImplementation "android.arch.persistence.room: testing:1.1.0"
  • 15. Important annotations • @Entity – by using this annotation, Room will know that this class will be a table in the database and the table name will define the name of the table • @PrimaryKey – is used to set up the primary key of the table. • @ColumnInfo – defines the name of the column from the table if we don’t want to use the name of that field • You also need to add getters and setters.
  • 17. Details about DAO • @Dao – by using this annotation Room knows that it should provide the implementation for our interface by generating code for the defined methods. • In this interface we could define the CRUD operations for our entity and also any other operations that are necessary in order to obtain the data. • Also Room offers us query validation at compilation time, so if we will write incorrectly the name of a table or a field we will know if after the code will be compiled.
  • 20.
  • 21.