SlideShare a Scribd company logo
1 of 21
Content
Provider
Android Training
By Khaled Anaqwa
Content Providers
 Content providers manage access to a
structured set of data.
 Encapsulate the data, and provide
mechanisms for defining data security.
 Content providers are the standard
interface that connects data in one
process with code running in another
process.
Access data in a content
provider
 you use the ContentResolver object in your
application's Context to communicate with
the provider as a client.
 The ContentResolver object communicates
with the provider object, an instance of a
class that implements ContentProvider.
 The provider object receives data requests
from clients, performs the requested action,
and returns the results.
Calendar Provider part of
Android platform
 Calendar Provider
 Contacts Provider
Calendar Provider
 The Calendar Provider is a repository for a
user's calendar events.
 The Calendar Provider API allows you to
perform query, insert, update, and delete
operations on calendars, events,
attendees, reminders, and so on
 Every content provider exposes a public URI
(wrapped as a Uri object) that uniquely identifies its
data set.
 A content provider that controls multiple data sets
(multiple tables) exposes a separate URI for each
one.
 All URIs for providers begin with the string "content://".
 This identifies the data as being controlled by a
content provider.
 The Calendar Provider defines constants for the URIs
for each of its classes (tables). These URIs have the
format <class>.CONTENT_URI. For example,
Events.CONTENT_URI.
How To Use
 Uses Permissions
 ContentResolver
 Querying
Uses Permissions
<uses-permission
android:name="android.permission.READ_CAL
ENDAR" />
<uses-permission
android:name="android.permission.WRITE_CA
LENDAR" />
ContentResolver
ContentResolver cr = getContentResolver();
Uri uri = Calendars.CONTENT_URI;
Query Example
 Cursor c = cr.query(uri, projection,
selection, selectionArgs, null);
 update(updateUri, values, null, null);
 insert(Events.CONTENT_URI, values);
Demo
 Create Event add it to calendar
 Adding Reminder
Task
 Select all events
Contacts Provider
 It’s a powerful and flexible Android component
that manages the device's central repository of
data about people.
 It’s the source of data you see in the device's
(contacts application , or your own application)
and transfer data between the device and online
services.
 It’s accommodates a wide range of data sources
and tries to manage as much data as possible for
each person, ( its organization is complex)
 Because of this, it's includes an extensive set of
contract classes and interfaces that facilitate both
data retrieval and modification.
Contacts Provider
Organization
 The Contacts Provider is an Android
content provider component. It maintains
three types of data about a person, each
of which corresponds to a table offered
by the provider
 The three tables are commonly referred to
by the names of their contract classes
 ContactsContract.Contacts table
Rows representing different people, based on
aggregations of raw contact rows.
 ContactsContract.RawContacts table
Rows containing a summary of a person's data,
specific to a user account and type.
 ContactsContract.Data table
Rows containing the details for raw contact,
such as email addresses or phone numbers.
Demo
 Open Contact Manager form Samples
 Task
 Modify List of Contacts add (_ID ,
HAS_PHONE_NUMBER )
Content Provider
 A content provider manages access to a central
repository of data.
 You implement a provider as one or more classes
in an Android application, along with elements in
the manifest file.
 One of your classes implements a subclass
ContentProvider, which is the interface between
your provider and other applications.
 Although content providers are meant to make
data available to other applications, you may of
course have activities in your application that
allow the user to query and modify the data
managed by your provider.
Before You Start Building C.P.
 You want to offer complex data or files to
other applications.
 You want to allow users to copy complex
data from your app into other apps.
 You want to provide custom search
suggestions using the search framework.
 You don't need a provider to use an
SQLite database if the use is entirely within
your own application.

More Related Content

What's hot

Android App Development - 10 Content providers
Android App Development - 10 Content providersAndroid App Development - 10 Content providers
Android App Development - 10 Content providersDiego Grancini
 
Content providers in Android
Content providers in AndroidContent providers in Android
Content providers in AndroidAlexey Ustenko
 
Android Training Session 1
Android Training Session 1Android Training Session 1
Android Training Session 1Shanmugapriya D
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIAhsanul Karim
 
Android Trainning Session 2
Android Trainning  Session 2Android Trainning  Session 2
Android Trainning Session 2Shanmugapriya D
 
ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON Padma shree. T
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptxCreate an android app for database creation using.pptx
Create an android app for database creation using.pptxvishal choudhary
 
Secure Sharing PHI PCI PII -Android app_Content Provider
Secure Sharing PHI PCI PII -Android app_Content ProviderSecure Sharing PHI PCI PII -Android app_Content Provider
Secure Sharing PHI PCI PII -Android app_Content ProviderAvinash Sinha
 
Recovered file 1
Recovered file 1Recovered file 1
Recovered file 1Uthara Iyer
 
Asp net interview_questions
Asp net interview_questionsAsp net interview_questions
Asp net interview_questionsBilam
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesArvind Krishnaa
 
Programming web application
Programming web applicationProgramming web application
Programming web applicationaspnet123
 
Lecture14Slides.ppt
Lecture14Slides.pptLecture14Slides.ppt
Lecture14Slides.pptVideoguy
 
Lesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPFLesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPFQuang Nguyễn Bá
 

What's hot (20)

Android App Development - 10 Content providers
Android App Development - 10 Content providersAndroid App Development - 10 Content providers
Android App Development - 10 Content providers
 
Content providers in Android
Content providers in AndroidContent providers in Android
Content providers in Android
 
Android Training Session 1
Android Training Session 1Android Training Session 1
Android Training Session 1
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Android Trainning Session 2
Android Trainning  Session 2Android Trainning  Session 2
Android Trainning Session 2
 
ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON
 
Ado Net
Ado NetAdo Net
Ado Net
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptxCreate an android app for database creation using.pptx
Create an android app for database creation using.pptx
 
Secure Sharing PHI PCI PII -Android app_Content Provider
Secure Sharing PHI PCI PII -Android app_Content ProviderSecure Sharing PHI PCI PII -Android app_Content Provider
Secure Sharing PHI PCI PII -Android app_Content Provider
 
Recovered file 1
Recovered file 1Recovered file 1
Recovered file 1
 
Android - Saving data
Android - Saving dataAndroid - Saving data
Android - Saving data
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
 
Asp net interview_questions
Asp net interview_questionsAsp net interview_questions
Asp net interview_questions
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View Classes
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Ado.net
Ado.netAdo.net
Ado.net
 
Lecture14Slides.ppt
Lecture14Slides.pptLecture14Slides.ppt
Lecture14Slides.ppt
 
Lesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPFLesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPF
 
Simple Data Binding
Simple Data BindingSimple Data Binding
Simple Data Binding
 
Lesson 05 Data Binding in WPF
Lesson 05 Data Binding in WPFLesson 05 Data Binding in WPF
Lesson 05 Data Binding in WPF
 

Viewers also liked

Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Khaled Anaqwa
 
Android - Broadcast Receiver
Android - Broadcast ReceiverAndroid - Broadcast Receiver
Android - Broadcast ReceiverYong Heui Cho
 
Improving Android Text Layout in Localisation
Improving Android Text Layout in LocalisationImproving Android Text Layout in Localisation
Improving Android Text Layout in LocalisationCharles Harley
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android Aakash Ugale
 
Structural Relationship between Content Resolver and Content Provider of Andr...
Structural Relationship between Content Resolver and Content Provider of Andr...Structural Relationship between Content Resolver and Content Provider of Andr...
Structural Relationship between Content Resolver and Content Provider of Andr...Somenath Mukhopadhyay
 
Android UI Testing with uiautomator
Android UI Testing with uiautomatorAndroid UI Testing with uiautomator
Android UI Testing with uiautomatorJana Moudrá
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic GuideAKASH SINGH
 
Android Training (android fundamental)
Android Training (android fundamental)Android Training (android fundamental)
Android Training (android fundamental)Khaled Anaqwa
 
Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)Khaled Anaqwa
 
Android Training (Services)
Android Training (Services)Android Training (Services)
Android Training (Services)Khaled Anaqwa
 
Android Training (Touch)
Android Training (Touch)Android Training (Touch)
Android Training (Touch)Khaled Anaqwa
 
Android training (android style)
Android training (android style)Android training (android style)
Android training (android style)Khaled Anaqwa
 
Android Training (Notifications)
Android Training (Notifications)Android Training (Notifications)
Android Training (Notifications)Khaled Anaqwa
 
Android Training (ScrollView , Horizontal ScrollView WebView)
Android Training (ScrollView , Horizontal ScrollView  WebView)Android Training (ScrollView , Horizontal ScrollView  WebView)
Android Training (ScrollView , Horizontal ScrollView WebView)Khaled Anaqwa
 
Chapter 5 ms access-1
Chapter 5   ms access-1Chapter 5   ms access-1
Chapter 5 ms access-1Pratik Gupta
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentAhsanul Karim
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureVijay Rastogi
 

Viewers also liked (20)

Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
 
Android - Broadcast Receiver
Android - Broadcast ReceiverAndroid - Broadcast Receiver
Android - Broadcast Receiver
 
Improving Android Text Layout in Localisation
Improving Android Text Layout in LocalisationImproving Android Text Layout in Localisation
Improving Android Text Layout in Localisation
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Structural Relationship between Content Resolver and Content Provider of Andr...
Structural Relationship between Content Resolver and Content Provider of Andr...Structural Relationship between Content Resolver and Content Provider of Andr...
Structural Relationship between Content Resolver and Content Provider of Andr...
 
Android UI Testing with uiautomator
Android UI Testing with uiautomatorAndroid UI Testing with uiautomator
Android UI Testing with uiautomator
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic Guide
 
Android Firebase
Android FirebaseAndroid Firebase
Android Firebase
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 
Android Training (android fundamental)
Android Training (android fundamental)Android Training (android fundamental)
Android Training (android fundamental)
 
Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)
 
Android Training (Services)
Android Training (Services)Android Training (Services)
Android Training (Services)
 
Android Training (Touch)
Android Training (Touch)Android Training (Touch)
Android Training (Touch)
 
Android training (android style)
Android training (android style)Android training (android style)
Android training (android style)
 
Android Training (Notifications)
Android Training (Notifications)Android Training (Notifications)
Android Training (Notifications)
 
Android Training (ScrollView , Horizontal ScrollView WebView)
Android Training (ScrollView , Horizontal ScrollView  WebView)Android Training (ScrollView , Horizontal ScrollView  WebView)
Android Training (ScrollView , Horizontal ScrollView WebView)
 
Chapter 5 ms access-1
Chapter 5   ms access-1Chapter 5   ms access-1
Chapter 5 ms access-1
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver Component
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 

Similar to Android Training (Content Provider)

Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?DicodingEvent
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfAbdullahMunir32
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfAbdullahMunir32
 
Mobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfMobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfAbdullahMunir32
 
Service-Finder presentation at ESTC2008
Service-Finder presentation at ESTC2008Service-Finder presentation at ESTC2008
Service-Finder presentation at ESTC2008servicefinder
 
Realizing Service Finder at ESTC 2008
Realizing Service Finder at ESTC 2008Realizing Service Finder at ESTC 2008
Realizing Service Finder at ESTC 2008Emanuele Della Valle
 
Documentum introduction
Documentum introductionDocumentum introduction
Documentum introductionotnawrup
 
5 steps to becoming a JISC IE content provider
5 steps to becoming a JISC IE content provider5 steps to becoming a JISC IE content provider
5 steps to becoming a JISC IE content providerAndy Powell
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJerry Kurian
 
Web Service Discovery Mechanisms Based on IR Models
Web Service Discovery Mechanisms Based on IR ModelsWeb Service Discovery Mechanisms Based on IR Models
Web Service Discovery Mechanisms Based on IR ModelsIRJET Journal
 
Building nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesBuilding nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesDavid McCarter
 
Android Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxAndroid Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxKNANTHINIMCA
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications developmentAlfredo Morresi
 
Efficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clusteringEfficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clusteringAlexander Decker
 
Azure Incident Response Cheat Sheet.pdf
Azure Incident Response Cheat Sheet.pdfAzure Incident Response Cheat Sheet.pdf
Azure Incident Response Cheat Sheet.pdfChristopher Doman
 

Similar to Android Training (Content Provider) (20)

Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdf
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Mobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdfMobile Application Development Lecture 05 & 06.pdf
Mobile Application Development Lecture 05 & 06.pdf
 
Service-Finder presentation at ESTC2008
Service-Finder presentation at ESTC2008Service-Finder presentation at ESTC2008
Service-Finder presentation at ESTC2008
 
Realizing Service Finder at ESTC 2008
Realizing Service Finder at ESTC 2008Realizing Service Finder at ESTC 2008
Realizing Service Finder at ESTC 2008
 
Documentum introduction
Documentum introductionDocumentum introduction
Documentum introduction
 
5 steps to becoming a JISC IE content provider
5 steps to becoming a JISC IE content provider5 steps to becoming a JISC IE content provider
5 steps to becoming a JISC IE content provider
 
REST
RESTREST
REST
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with Java
 
Web Service Discovery Mechanisms Based on IR Models
Web Service Discovery Mechanisms Based on IR ModelsWeb Service Discovery Mechanisms Based on IR Models
Web Service Discovery Mechanisms Based on IR Models
 
Building nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesBuilding nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework Services
 
Interoperability in Digital Libraries
Interoperability in Digital LibrariesInteroperability in Digital Libraries
Interoperability in Digital Libraries
 
Android Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxAndroid Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptx
 
Cloud as Gift
Cloud as GiftCloud as Gift
Cloud as Gift
 
Android resources in android-chapter9
Android resources in android-chapter9Android resources in android-chapter9
Android resources in android-chapter9
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
Efficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clusteringEfficient retrieval of web services using prioritization and clustering
Efficient retrieval of web services using prioritization and clustering
 
android
androidandroid
android
 
Azure Incident Response Cheat Sheet.pdf
Azure Incident Response Cheat Sheet.pdfAzure Incident Response Cheat Sheet.pdf
Azure Incident Response Cheat Sheet.pdf
 

More from Khaled Anaqwa

Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Khaled Anaqwa
 
Android Training (Animation)
Android Training (Animation)Android Training (Animation)
Android Training (Animation)Khaled Anaqwa
 
Android Training (Sensors)
Android Training (Sensors)Android Training (Sensors)
Android Training (Sensors)Khaled Anaqwa
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)Khaled Anaqwa
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Khaled Anaqwa
 
Android Training (Android UI)
Android Training (Android UI)Android Training (Android UI)
Android Training (Android UI)Khaled Anaqwa
 
Android Training (Intro)
Android Training (Intro)Android Training (Intro)
Android Training (Intro)Khaled Anaqwa
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 

More from Khaled Anaqwa (8)

Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
 
Android Training (Animation)
Android Training (Animation)Android Training (Animation)
Android Training (Animation)
 
Android Training (Sensors)
Android Training (Sensors)Android Training (Sensors)
Android Training (Sensors)
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)
 
Android Training (Android UI)
Android Training (Android UI)Android Training (Android UI)
Android Training (Android UI)
 
Android Training (Intro)
Android Training (Intro)Android Training (Intro)
Android Training (Intro)
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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 pragmaticscarlostorres15106
 
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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

Android Training (Content Provider)

  • 2. Content Providers  Content providers manage access to a structured set of data.  Encapsulate the data, and provide mechanisms for defining data security.  Content providers are the standard interface that connects data in one process with code running in another process.
  • 3. Access data in a content provider  you use the ContentResolver object in your application's Context to communicate with the provider as a client.  The ContentResolver object communicates with the provider object, an instance of a class that implements ContentProvider.  The provider object receives data requests from clients, performs the requested action, and returns the results.
  • 4. Calendar Provider part of Android platform  Calendar Provider  Contacts Provider
  • 5. Calendar Provider  The Calendar Provider is a repository for a user's calendar events.  The Calendar Provider API allows you to perform query, insert, update, and delete operations on calendars, events, attendees, reminders, and so on
  • 6.  Every content provider exposes a public URI (wrapped as a Uri object) that uniquely identifies its data set.  A content provider that controls multiple data sets (multiple tables) exposes a separate URI for each one.  All URIs for providers begin with the string "content://".  This identifies the data as being controlled by a content provider.  The Calendar Provider defines constants for the URIs for each of its classes (tables). These URIs have the format <class>.CONTENT_URI. For example, Events.CONTENT_URI.
  • 7.
  • 8. How To Use  Uses Permissions  ContentResolver  Querying
  • 10. ContentResolver ContentResolver cr = getContentResolver(); Uri uri = Calendars.CONTENT_URI;
  • 11. Query Example  Cursor c = cr.query(uri, projection, selection, selectionArgs, null);  update(updateUri, values, null, null);  insert(Events.CONTENT_URI, values);
  • 12. Demo  Create Event add it to calendar  Adding Reminder
  • 14. Contacts Provider  It’s a powerful and flexible Android component that manages the device's central repository of data about people.  It’s the source of data you see in the device's (contacts application , or your own application) and transfer data between the device and online services.  It’s accommodates a wide range of data sources and tries to manage as much data as possible for each person, ( its organization is complex)  Because of this, it's includes an extensive set of contract classes and interfaces that facilitate both data retrieval and modification.
  • 15. Contacts Provider Organization  The Contacts Provider is an Android content provider component. It maintains three types of data about a person, each of which corresponds to a table offered by the provider
  • 16.
  • 17.  The three tables are commonly referred to by the names of their contract classes  ContactsContract.Contacts table Rows representing different people, based on aggregations of raw contact rows.  ContactsContract.RawContacts table Rows containing a summary of a person's data, specific to a user account and type.  ContactsContract.Data table Rows containing the details for raw contact, such as email addresses or phone numbers.
  • 18. Demo  Open Contact Manager form Samples  Task  Modify List of Contacts add (_ID , HAS_PHONE_NUMBER )
  • 19. Content Provider  A content provider manages access to a central repository of data.  You implement a provider as one or more classes in an Android application, along with elements in the manifest file.  One of your classes implements a subclass ContentProvider, which is the interface between your provider and other applications.  Although content providers are meant to make data available to other applications, you may of course have activities in your application that allow the user to query and modify the data managed by your provider.
  • 20. Before You Start Building C.P.  You want to offer complex data or files to other applications.  You want to allow users to copy complex data from your app into other apps.  You want to provide custom search suggestions using the search framework.
  • 21.  You don't need a provider to use an SQLite database if the use is entirely within your own application.

Editor's Notes

  1. long calID = 3; long startMillis = 0; long endMillis = 0; Calendar beginTime = Calendar.getInstance(); beginTime.set(2012, 9, 14, 7, 30); startMillis = beginTime.getTimeInMillis(); Calendar endTime = Calendar.getInstance(); endTime.set(2012, 9, 14, 8, 45); endMillis = endTime.getTimeInMillis(); ContentResolver cr = getContentResolver(); ContentValues values = new ContentValues(); values.put(Events.DTSTART, startMillis); values.put(Events.DTEND, endMillis); values.put(Events.TITLE, "Jazzercise"); values.put(Events.DESCRIPTION, "Group workout"); values.put(Events.CALENDAR_ID, calID); values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles"); Uri uri = cr.insert(Events.CONTENT_URI, values); // get the event ID that is the last element in the Uri long eventID = Long.parseLong(uri.getLastPathSegment()); //add reminder ContentResolver cr = getContentResolver(); ContentValues values = new ContentValues(); values.put(Reminders.MINUTES, 15); values.put(Reminders.EVENT_ID, eventID); values.put(Reminders.METHOD, Reminders.METHOD_ALERT); Uri uri = cr.insert(Reminders.CONTENT_URI, values);
  2. public static final String[] INSTANCE_PROJECTION = new String[] { Instances.EVENT_ID, // 0 Instances.BEGIN, // 1 Instances.TITLE // 2 }; // The indices for the projection array above. private static final int PROJECTION_ID_INDEX = 0; private static final int PROJECTION_BEGIN_INDEX = 1; private static final int PROJECTION_TITLE_INDEX = 2; alendar beginTime = Calendar.getInstance(); beginTime.set(2011, 9, 23, 8, 0); long startMillis = beginTime.getTimeInMillis(); Calendar endTime = Calendar.getInstance(); endTime.set(2011, 10, 24, 8, 0); long endMillis = endTime.getTimeInMillis(); Cursor cur = null; ContentResolver cr = getContentResolver(); // The ID of the recurring event whose instances you are searching // for in the Instances table String selection = Instances.EVENT_ID + " = ?"; String[] selectionArgs = new String[] {"207"}; // Construct the query with the desired date range. Uri.Builder builder = Instances.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, startMillis); ContentUris.appendId(builder, endMillis); // Submit the query cur = cr.query(builder.build(), INSTANCE_PROJECTION, selection, selectionArgs, null); while (cur.moveToNext()) { String title = null; long eventID = 0; long beginVal = 0; // Get the field values eventID = cur.getLong(PROJECTION_ID_INDEX); beginVal = cur.getLong(PROJECTION_BEGIN_INDEX); title = cur.getString(PROJECTION_TITLE_INDEX); // Do something with the values. Log.i(DEBUG_TAG, "Event: " + title); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(beginVal); DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Log.i(DEBUG_TAG, "Date: " + formatter.format(calendar.getTime())); } }