SlideShare a Scribd company logo
Android Manchester
Week 6 - Content Providers
Overview
● Sponsor Message - Novoda
● Retro
○ Lesson 4b ContentProviders
● Looking forward
○ Lesson 4c Loaders
● Stickers + Booklets
● Participant Survey
● Next Tue 7-8pm SpacePortX
Energizer
Stand up and introduce yourself to
somebody around you, you don’t
know
Prime Directive
‘Regardless of where we are up to, we
understand and truly believe that
everyone did the best job he or she
could, given his or her skills and
abilities, the personal time available,
and the situation at hand.’
Difficulty Check
● Who completed the class?
● How long did it take?
● Hands up 1-10 difficulty of the weeks lesson
● Any specific areas of the lesson that require
particular focus?
Retro lesson 4b Content Providers
What we learnt last week
● Content Provider API
● Sharing Data
● Uri Matching
● Efficiency with bulk inserts
Why Content Providers
● Share data across process
(one app to another)
○ Security
○ Standard API
○ Ease of use
● Share data within app
(one component to another)
○ Framework considers all data
to come from ContentProdviders
○ Abstract underlying datasource
○ Separates UI code from data layers
Bonus Lesson
https://www.udacity.com/course/ud258
UserDictionaryContentProvider
What is a ContentResolver
What is a Uri
● Uri is a superset of URL
● Defines the type or location of a resource
What is a Cursor
Putting it all together
Updating WeatherContract
● Agreement between data model & UI on how
data is accessed
● Define Uri’s for how to access data
● Content Authority (package name)
● Base Uri (content provider base)
● Path (table name)
● MimeType
UriMatchers
● Mapping from Uri to Integer
● Allows a way to use the Uri as a key
● Can then be used in switch statement
● * is String
● # is Number
● http://developer.android.com/reference/android/content/UriMatcher.html
UriMatcher code example
public String getType(Uri url) {
int match = sURIMatcher.match(url);
switch (match) {
case PEOPLE:
return "vnd.android.cursor.dir/person";
case PEOPLE_ID:
return "vnd.android.cursor.item/person";
... snip ...
return "vnd.android.cursor.dir/snail-mail";
case PEOPLE_ADDRESS_ID:
return "vnd.android.cursor.item/snail-mail";
default:
return null;
}
}
public String getType(Uri url) {
List pathSegments = url.getPathSegments();
if (pathSegments.size() >= 2) {
if ("people".equals(pathSegments.get(1))) {
if (pathSegments.size() == 2) {
return "vnd.android.cursor.dir/person";
} else if (pathSegments.size() == 3) {
return "vnd.android.cursor.item/person";
... snip ...
return "vnd.android.cursor.dir/snail-mail";
} else if (pathSegments.size() == 3) {
return "vnd.android.cursor.item/snail-mail";
}
}
}
return null;
}
● Register ContentProvider in AndroidManifest
● ContentResolver talks to ContentProvider
● Uses your Authority to locate Provider
● Returns Cursor’s to manipulate
● ProTip: use Gradle to create 1 constant for authority
string
ContentResolver
Content Provider
● Uses WeatherContract
● Uses WeatherDbHelper
● Uses UriMatcher
● query(), insert(), delete(), update()
● getType
○ type item or type directory
○ returns content type (Mime type)
● setNotificationUri() registers ContentObserver
○ notify UI when content changes (insert, update)
Data change notifications
● notifyChange() on ContentResolver
● Notifying the base notifies all descendents
● Be careful which uri you choose to watch
● Loaders take advantage of this mechanism
Efficient Inserts
● ContentProvider.bulkInsert
● Much more efficient than multiple single
imports
● beginTransaction() & endTransaction()
● setTransactionSuccessful() or insert is rolled
back
Let someone else do it - Libraries
https://github.com/novoda/sqlite-provider
- Convention Uri queries
- No need to create DatabaseHelper
- Create database using SQL files in /assets/
- Just create the contract class and thats it
https://github.com/novoda/sqlite-analyzer
- Creates the contract class for you
- Based on SQL files in /assets/ or existing database
What went well
What went well
● Tests for ContentProvider given to sanity
check against
● The secondary lesson was great at
explaining ContentProviders (https://www.
udacity.com/course/ud258)
What didn’t go so well
What didn’t go so well
● Did anyone actually use or run the tests?
( I didn’t bother)
● Talking about Joins - not android
necessity
● Don’t close your database! (instructor
notes)
● Queries on the UI thread
Q&A
Next Week - Android
Jam
Loaders
Next Lesson - Loaders
Learning Objectives:
- Creating a Loader
- Advantages & Disadvantages
- CursorLoader
- CursorAdapter
- Projections
- Leveraging the content provider
http://novoda.com
Liverpool, London, Berlin
Absolutely Liverpool
Thurs 12th March
See you next week..
- Time: Tuesday 7pm
- Place: SpacePort
- Things needed: You + Questions +
Feedback
- Can contact us if issues:
@blundell_apps / @android_mcr
Go forth and discuss

More Related Content

Viewers also liked

6 b magazine conventions (cole robinson)
6 b   magazine conventions (cole robinson)6 b   magazine conventions (cole robinson)
6 b magazine conventions (cole robinson)Crobinson17
 
AWH Almost Ultimate_App_ebook
AWH Almost Ultimate_App_ebookAWH Almost Ultimate_App_ebook
AWH Almost Ultimate_App_ebookRyan Frederick
 
6 b magazine conventions (cole robinson)
6 b   magazine conventions (cole robinson)6 b   magazine conventions (cole robinson)
6 b magazine conventions (cole robinson)Crobinson17
 
Narayana Murthy
Narayana Murthy Narayana Murthy
Narayana Murthy Sagar Garg
 
Sociolinguistics and Phonology of Kanauji
Sociolinguistics and Phonology of KanaujiSociolinguistics and Phonology of Kanauji
Sociolinguistics and Phonology of KanaujiPankaj Dwivedi
 
6 b magazine conventions (cole robinson)
6 b   magazine conventions (cole robinson)6 b   magazine conventions (cole robinson)
6 b magazine conventions (cole robinson)Crobinson17
 
Voter count for the coming 2K14
Voter count for the coming 2K14Voter count for the coming 2K14
Voter count for the coming 2K14Ilendra Vyas
 
The communication process
The communication processThe communication process
The communication processAlvin La Torre
 

Viewers also liked (13)

Evaluation stage
Evaluation stageEvaluation stage
Evaluation stage
 
La inocuidad alimentaria
La inocuidad alimentaria La inocuidad alimentaria
La inocuidad alimentaria
 
6 b magazine conventions (cole robinson)
6 b   magazine conventions (cole robinson)6 b   magazine conventions (cole robinson)
6 b magazine conventions (cole robinson)
 
AWH Almost Ultimate_App_ebook
AWH Almost Ultimate_App_ebookAWH Almost Ultimate_App_ebook
AWH Almost Ultimate_App_ebook
 
6 b magazine conventions (cole robinson)
6 b   magazine conventions (cole robinson)6 b   magazine conventions (cole robinson)
6 b magazine conventions (cole robinson)
 
Teamwork
Teamwork Teamwork
Teamwork
 
Narayana Murthy
Narayana Murthy Narayana Murthy
Narayana Murthy
 
Www mi40results-com
Www mi40results-comWww mi40results-com
Www mi40results-com
 
Sociolinguistics and Phonology of Kanauji
Sociolinguistics and Phonology of KanaujiSociolinguistics and Phonology of Kanauji
Sociolinguistics and Phonology of Kanauji
 
6 b magazine conventions (cole robinson)
6 b   magazine conventions (cole robinson)6 b   magazine conventions (cole robinson)
6 b magazine conventions (cole robinson)
 
Voter count for the coming 2K14
Voter count for the coming 2K14Voter count for the coming 2K14
Voter count for the coming 2K14
 
The communication process
The communication processThe communication process
The communication process
 
My technology timeline
My technology timelineMy technology timeline
My technology timeline
 

Similar to Android Jam - ContentProviders - Udacity Lesson 4b

Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014Dimitar Danailov
 
Android developer fundamentals training overview Part II
Android developer fundamentals training overview Part IIAndroid developer fundamentals training overview Part II
Android developer fundamentals training overview Part IIYoza Aprilio
 
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018Holden Karau
 
Programming for Performance
Programming for PerformanceProgramming for Performance
Programming for PerformanceCris Holdorph
 
Open Chemistry, JupyterLab and data: Reproducible quantum chemistry
Open Chemistry, JupyterLab and data: Reproducible quantum chemistryOpen Chemistry, JupyterLab and data: Reproducible quantum chemistry
Open Chemistry, JupyterLab and data: Reproducible quantum chemistryMarcus Hanwell
 
Labeling all the Things with the WDI Skill Labeler
Labeling all the Things with the WDI Skill Labeler Labeling all the Things with the WDI Skill Labeler
Labeling all the Things with the WDI Skill Labeler Kwame Porter Robinson
 
DevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and ProjectsDevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and ProjectsFedir RYKHTIK
 
Deploying Linked Open Data: Methodologies and Software Tools
Deploying Linked Open Data: Methodologies and Software ToolsDeploying Linked Open Data: Methodologies and Software Tools
Deploying Linked Open Data: Methodologies and Software ToolsNikolaos Konstantinou
 
Design | expose ap is with cqr
Design | expose ap is with cqrDesign | expose ap is with cqr
Design | expose ap is with cqrJabar Asadi
 
BISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesBISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesSrinath Perera
 
Design | expose ap is with cqrs
Design | expose ap is with cqrsDesign | expose ap is with cqrs
Design | expose ap is with cqrselazhiA
 
Deep Recommender systems - Shibsted, Oslo
Deep Recommender systems - Shibsted, OsloDeep Recommender systems - Shibsted, Oslo
Deep Recommender systems - Shibsted, OsloMax Pumperla
 
WEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
WEBINAR: Proven Patterns for Loading Test Data for Managed Package TestingWEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
WEBINAR: Proven Patterns for Loading Test Data for Managed Package TestingCodeScience
 
Hong Kong Drupal User Group - 2014 April 12th
Hong Kong Drupal User Group - 2014 April 12thHong Kong Drupal User Group - 2014 April 12th
Hong Kong Drupal User Group - 2014 April 12thWong Hoi Sing Edison
 
Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...
Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...
Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...Neo4j
 
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...StormForge .io
 

Similar to Android Jam - ContentProviders - Udacity Lesson 4b (20)

Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014
 
Android developer fundamentals training overview Part II
Android developer fundamentals training overview Part IIAndroid developer fundamentals training overview Part II
Android developer fundamentals training overview Part II
 
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
 
Programming for Performance
Programming for PerformanceProgramming for Performance
Programming for Performance
 
Open Chemistry, JupyterLab and data: Reproducible quantum chemistry
Open Chemistry, JupyterLab and data: Reproducible quantum chemistryOpen Chemistry, JupyterLab and data: Reproducible quantum chemistry
Open Chemistry, JupyterLab and data: Reproducible quantum chemistry
 
Labeling all the Things with the WDI Skill Labeler
Labeling all the Things with the WDI Skill Labeler Labeling all the Things with the WDI Skill Labeler
Labeling all the Things with the WDI Skill Labeler
 
DevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and ProjectsDevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and Projects
 
Deploying Linked Open Data: Methodologies and Software Tools
Deploying Linked Open Data: Methodologies and Software ToolsDeploying Linked Open Data: Methodologies and Software Tools
Deploying Linked Open Data: Methodologies and Software Tools
 
Publishing Linked Data using Schema.org
Publishing Linked Data using Schema.orgPublishing Linked Data using Schema.org
Publishing Linked Data using Schema.org
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
Design | expose ap is with cqr
Design | expose ap is with cqrDesign | expose ap is with cqr
Design | expose ap is with cqr
 
BISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesBISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple Spaces
 
Design | expose ap is with cqrs
Design | expose ap is with cqrsDesign | expose ap is with cqrs
Design | expose ap is with cqrs
 
Deep Recommender systems - Shibsted, Oslo
Deep Recommender systems - Shibsted, OsloDeep Recommender systems - Shibsted, Oslo
Deep Recommender systems - Shibsted, Oslo
 
WEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
WEBINAR: Proven Patterns for Loading Test Data for Managed Package TestingWEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
WEBINAR: Proven Patterns for Loading Test Data for Managed Package Testing
 
Hong Kong Drupal User Group - 2014 April 12th
Hong Kong Drupal User Group - 2014 April 12thHong Kong Drupal User Group - 2014 April 12th
Hong Kong Drupal User Group - 2014 April 12th
 
Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...
Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...
Discovering Emerging Tech through Graph Analysis - Henry Hwangbo @ GraphConne...
 
Sebastian Hellmann
Sebastian HellmannSebastian Hellmann
Sebastian Hellmann
 
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 

More from Paul Blundell

In 10 mins a software crafting journey
In 10 mins a software crafting journeyIn 10 mins a software crafting journey
In 10 mins a software crafting journeyPaul Blundell
 
The Novoda Craft University
The Novoda Craft UniversityThe Novoda Craft University
The Novoda Craft UniversityPaul Blundell
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid FoundationsPaul Blundell
 
Http Caching for the Android Aficionado
Http Caching for the Android AficionadoHttp Caching for the Android Aficionado
Http Caching for the Android AficionadoPaul Blundell
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsPaul Blundell
 
Java Patterns - Strategy
Java Patterns - StrategyJava Patterns - Strategy
Java Patterns - StrategyPaul Blundell
 
Survival of the Continuist
Survival of the ContinuistSurvival of the Continuist
Survival of the ContinuistPaul Blundell
 
Google I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsGoogle I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsPaul Blundell
 
Android Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cAndroid Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cPaul Blundell
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationPaul Blundell
 
Jenkins project based authorization
Jenkins   project based authorizationJenkins   project based authorization
Jenkins project based authorizationPaul Blundell
 
Judge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughJudge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughPaul Blundell
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kataPaul Blundell
 

More from Paul Blundell (14)

In 10 mins a software crafting journey
In 10 mins a software crafting journeyIn 10 mins a software crafting journey
In 10 mins a software crafting journey
 
The Novoda Craft University
The Novoda Craft UniversityThe Novoda Craft University
The Novoda Craft University
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid Foundations
 
Http Caching for the Android Aficionado
Http Caching for the Android AficionadoHttp Caching for the Android Aficionado
Http Caching for the Android Aficionado
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussions
 
Java Patterns - Strategy
Java Patterns - StrategyJava Patterns - Strategy
Java Patterns - Strategy
 
Survival of the Continuist
Survival of the ContinuistSurvival of the Continuist
Survival of the Continuist
 
Google I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsGoogle I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech Announcements
 
Android Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cAndroid Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4c
 
Y U NO CRAFTSMAN
Y U NO CRAFTSMANY U NO CRAFTSMAN
Y U NO CRAFTSMAN
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 
Jenkins project based authorization
Jenkins   project based authorizationJenkins   project based authorization
Jenkins project based authorization
 
Judge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughJudge my gym - GymBabes Walkthrough
Judge my gym - GymBabes Walkthrough
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationZilliz
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 

Android Jam - ContentProviders - Udacity Lesson 4b

  • 1. Android Manchester Week 6 - Content Providers
  • 2. Overview ● Sponsor Message - Novoda ● Retro ○ Lesson 4b ContentProviders ● Looking forward ○ Lesson 4c Loaders ● Stickers + Booklets ● Participant Survey ● Next Tue 7-8pm SpacePortX
  • 3. Energizer Stand up and introduce yourself to somebody around you, you don’t know
  • 4. Prime Directive ‘Regardless of where we are up to, we understand and truly believe that everyone did the best job he or she could, given his or her skills and abilities, the personal time available, and the situation at hand.’
  • 5. Difficulty Check ● Who completed the class? ● How long did it take? ● Hands up 1-10 difficulty of the weeks lesson ● Any specific areas of the lesson that require particular focus?
  • 6. Retro lesson 4b Content Providers What we learnt last week ● Content Provider API ● Sharing Data ● Uri Matching ● Efficiency with bulk inserts
  • 7. Why Content Providers ● Share data across process (one app to another) ○ Security ○ Standard API ○ Ease of use ● Share data within app (one component to another) ○ Framework considers all data to come from ContentProdviders ○ Abstract underlying datasource ○ Separates UI code from data layers
  • 9. What is a ContentResolver
  • 10. What is a Uri ● Uri is a superset of URL ● Defines the type or location of a resource
  • 11. What is a Cursor
  • 12. Putting it all together
  • 13. Updating WeatherContract ● Agreement between data model & UI on how data is accessed ● Define Uri’s for how to access data ● Content Authority (package name) ● Base Uri (content provider base) ● Path (table name) ● MimeType
  • 14. UriMatchers ● Mapping from Uri to Integer ● Allows a way to use the Uri as a key ● Can then be used in switch statement ● * is String ● # is Number ● http://developer.android.com/reference/android/content/UriMatcher.html
  • 15. UriMatcher code example public String getType(Uri url) { int match = sURIMatcher.match(url); switch (match) { case PEOPLE: return "vnd.android.cursor.dir/person"; case PEOPLE_ID: return "vnd.android.cursor.item/person"; ... snip ... return "vnd.android.cursor.dir/snail-mail"; case PEOPLE_ADDRESS_ID: return "vnd.android.cursor.item/snail-mail"; default: return null; } } public String getType(Uri url) { List pathSegments = url.getPathSegments(); if (pathSegments.size() >= 2) { if ("people".equals(pathSegments.get(1))) { if (pathSegments.size() == 2) { return "vnd.android.cursor.dir/person"; } else if (pathSegments.size() == 3) { return "vnd.android.cursor.item/person"; ... snip ... return "vnd.android.cursor.dir/snail-mail"; } else if (pathSegments.size() == 3) { return "vnd.android.cursor.item/snail-mail"; } } } return null; }
  • 16. ● Register ContentProvider in AndroidManifest ● ContentResolver talks to ContentProvider ● Uses your Authority to locate Provider ● Returns Cursor’s to manipulate ● ProTip: use Gradle to create 1 constant for authority string ContentResolver
  • 17. Content Provider ● Uses WeatherContract ● Uses WeatherDbHelper ● Uses UriMatcher ● query(), insert(), delete(), update() ● getType ○ type item or type directory ○ returns content type (Mime type) ● setNotificationUri() registers ContentObserver ○ notify UI when content changes (insert, update)
  • 18. Data change notifications ● notifyChange() on ContentResolver ● Notifying the base notifies all descendents ● Be careful which uri you choose to watch ● Loaders take advantage of this mechanism
  • 19. Efficient Inserts ● ContentProvider.bulkInsert ● Much more efficient than multiple single imports ● beginTransaction() & endTransaction() ● setTransactionSuccessful() or insert is rolled back
  • 20. Let someone else do it - Libraries https://github.com/novoda/sqlite-provider - Convention Uri queries - No need to create DatabaseHelper - Create database using SQL files in /assets/ - Just create the contract class and thats it https://github.com/novoda/sqlite-analyzer - Creates the contract class for you - Based on SQL files in /assets/ or existing database
  • 22. What went well ● Tests for ContentProvider given to sanity check against ● The secondary lesson was great at explaining ContentProviders (https://www. udacity.com/course/ud258)
  • 23. What didn’t go so well
  • 24. What didn’t go so well ● Did anyone actually use or run the tests? ( I didn’t bother) ● Talking about Joins - not android necessity ● Don’t close your database! (instructor notes) ● Queries on the UI thread
  • 25. Q&A
  • 26. Next Week - Android Jam Loaders
  • 27. Next Lesson - Loaders Learning Objectives: - Creating a Loader - Advantages & Disadvantages - CursorLoader - CursorAdapter - Projections - Leveraging the content provider
  • 30. See you next week.. - Time: Tuesday 7pm - Place: SpacePort - Things needed: You + Questions + Feedback - Can contact us if issues: @blundell_apps / @android_mcr
  • 31. Go forth and discuss