Content Provider. Introduction 01/03/2016. Session objectives. Content providers. Android programming course. Introduction. Built-in Content Provider

Similar documents
CS371m - Mobile Computing. Content Providers And Content Resolvers

Data storage and exchange in Android

Learn about Android Content Providers and SQLite

Mobile Application Development Android

Lecture 2 Android SDK

Application Fundamentals

Mobile Application Development Android

Mobile Application Development Android

Automatically persisted among application sessions

How-to s and presentations. Be prepared to demo them in class. ons

CS378 -Mobile Computing. Content Providers

CS378 -Mobile Computing. Persistence -SQLite

SharedPreference. <map> <int name="access_count" value="3" /> </map>

Android Programming - Jelly Bean

CMSC436: Fall 2013 Week 4 Lab

Mobile Programming Lecture 10. ContentProviders

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Change in Orientation. Marco Ronchetti Università degli Studi di Trento

Mobile Computing. Introduction to Android

Spring Lecture 5 Lecturer: Omid Jafarinezhad

App Development for Smart Devices. Lec #5: Content Provider

Aim behind client server architecture Characteristics of client and server Types of architectures

ContentProvider & ContentResolver ContentResolver methods CursorLoader Implementing ContentProviders

ORACLE UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

SHWETANK KUMAR GUPTA Only For Education Purpose

Writing Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations

The Basis of Data. Steven R. Bagley

CS371m - Mobile Computing. Persistence - SQLite

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

Linked data from your pocket: The Android RDFContentProvider

M.C.A. Semester V Subject: - Mobile Computing (650003) Week : 2

Syllabus- Java + Android. Java Fundamentals

CS378 -Mobile Computing. Intents

Object-Oriented Databases Object-Relational Mappings and Frameworks. Alexandre de Spindler Department of Computer Science

Minds-on: Android. Session 2

Linked data from your pocket

PES INSTITUTE OF TECHNOLOGY (BSC) IV MCA, Second IA Test, May 2017 Mobile Applications (13MCA456) Solution Set Faculty: Jeny Jijo

Q&As. Microsoft MTA Software Development Fundamentals. Pass Microsoft Exam with 100% Guarantee

Android Tutorial: Part 3

ANDROID TRAINING PROGRAM COURSE CONTENT

Activities and Fragments

Android App Development

Android Application Development 101. Jason Chen Google I/O 2008

Implementing a Download Background Service

Android Ecosystem and. Revised v4presenter. What s New

Android Programming in Bluetooth Cochlea Group

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle

JAVA+ANDROID CURRICULUM 6 WEEKS. INTRODUCTION TO JAVA Understanding Requirement: Why Java Why Java is important to the Internet JAVA on LINUX Platform

Java Training Center - Android Application Development

BryteWave K-12 Edition

Answers to Exercises

BryteWave K-12 Edition

A Tour of Android. and some of it s APIs. Bryan Noll

ANDROID APPLICATION DEVELOPMENT COURSE Training Program

Android Camera. Alexander Nelson October 6, University of Arkansas - Department of Computer Science and Computer Engineering

Android: Data Storage

Lecture 08. Android Permissions Demystified. Adrienne Porter Felt, Erika Chin, Steve Hanna, Dawn Song, David Wagner. Operating Systems Practical

FreeRangeRemote Access

Android Overview. Most of the material in this section comes from

CS Android. Vitaly Shmatikov

Android Services & Local IPC: The Command Processor Pattern (Part 1)

Software Development & Education Center ANDROID. Application Development

CHAPTER 7 WEB SERVERS AND WEB BROWSERS

Android SQLite Essentials

An Introduction to Android. Jason Chen Developer Advocate Google I/O 2008

Software Engineering Large Practical: Preferences, storage, and testing

Accelerating Information Technology Innovation

Understanding Application

Android Essentials with Java

3 Setting BI Launch Pad and Web Intelligence Preferences

Android App Development for Beginners

Android Internals and the Dalvik VM!

Topics Covered in the Android Apps Development Training

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Chapter 27 WWW and HTTP Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Android Programming (5 Days)

CORE JAVA& ANDROID SYLLABUS

Policy Based Device Access Security Position Paper to Device Access Policy Working Group

Android. Operating System and Architecture. Android. Screens. Main features

COURSE SYLLABUS ANDROID. Industrial Training (4 MONTHS) PH : , Vazhoor Road Changanacherry-01.

Distributed Multitiered Application

CS50 Quiz Review. November 13, 2017

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

Database Development In Android Applications

Basic 4 Android Object Browser Version 3.2.x.x. Development, design and documentation by Dave Robinson, aka Vader

Mobile Application Development

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence

Collection Information Menu. Navigation, pages, and related-links quickstart guide

SQLite Database. References. Overview. Structured Databases

Hibernate Interview Questions

Minds-on: Android. Session 1

Introduction to Mobile Application and Development

IGEEKS TECHNOLOGIES. Software Training Division. Academic Live Projects For BE,ME,MCA,BCA and PHD Students

For more information about the Cisco Jabber suite of products, see

Application Development

application components

CSCU9YH: Development with Android

CS378 -Mobile Computing. Services and Broadcast Receivers

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle

Transcription:

Android programming course Session objectives Introduction Built-in Custom By Võ Văn Hải Faculty of Information Technologies 2 Content providers Introduction Content providers manage access to a structured set of data. They 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. Such are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network. 3 4 1

Need for Overall structure Each Android applications runs in its own process with its own permissions which keeps an application data hidden from another application. But sometimes it is required to share data across applications. This is where content providers become very useful. Content providers let you centralize content in one place and have many different applications access it as needed. A content provider behaves very much like a database where you can query it, edit its content, as well as add or delete content using insert(), update(), delete(), and query() methods. In most cases this data is stored in an SQlite database. 5 Application #1 Activity #2 Activity #3 Database Files XML Remote connection Application #2 Application #3 Activity #2 An application accesses the data from a content provider with a ContentResolver client object. This object has methods that call identically-named methods in the provider object, an instance of one of the concrete subclasses of ContentProvider. The ContentResolver methods provide the basic "CRUD" (create, retrieve, update, and delete) functions of persistent storage. The ContentResolver object in the client application's process and the ContentProvider object in the application that owns the provider automatically handle inter-process communication. ContentProvider also acts as an abstraction layer between its repository of data and the external appearance of data as tables. 7 URI: Query Insert ContentResolver URI Update Delete content://com.example.provider/articles/<id> Scheme Authority Path 2

For example, to get a list of the words and their locales from the User Dictionary Provider, you call ContentResolver.query(). The query() method calls the ContentProvider.query() method defined by the User Dictionary Provider. The following lines of code show a ContentResolver.query() call: Built-in s 9 10 Built-in s Get all contacts example Some of Android's most useful built-in content providers, along with a description of the type of data they're intended to store Browser CallLog Contacts MediaStore Settings Intended Data Browser bookmarks, browser history, etc. Missed calls, call details, etc. Contact details Media files such as audio, video and images Device settings and preferences 11 <uses-permission android:name="android.permission.read_contacts" /> 12 3

Get all call log Get settings 13 <uses-permission android:name="android.permission.read_call_log" /> 14 Steps to create your own ContentProvider Create your own Content Provider 1. First of all you need to create a class that extends the ContentProvider base class. 2. Second, you need to define your content provider URI address which will be used to access the content. 3. Next you will need to create your own database to keep the content. Usually, Android uses SQLite database and framework needs to override oncreate() method which will use SQLite Open Helper method to create or open the provider's database. When your application is launched, the oncreate() handler of each of its s is called on the main application thread. 4. Next you will have to implement queries to perform different database specific operations. 5. Finally register your in your activity file using <provider> tag. 15 16 4

Call-back methods Example: ContentProvider class Here is the list of methods which you need to override in Content Provider class to have your working: oncreate() This method is called when the provider is started. query() This method receives a request from a client. The result is returned as a Cursor object. insert()this method inserts a new record into the content provider. delete() This method deletes an existing record from the content provider. update() This method updates an existing record from the content provider. gettype() This method returns the MIME type of the data at the given URI. 17 18 Example: Registering Example: Client call ContentProvider 19 20 5