ContentProviders. SQLite Database SQLite is a software library that implements aself- contained, serverless,zero- configuration,transactionalSQL database.

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Bruce Scharlau, University of Aberdeen, 2012 Data storage options for mobiles Mobile Computing.
 data/data-storage.html#pref data/data-storage.html#pref 
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
Browsing the World Wide Web. Spring 2002Computer Networks Applications Browsing Service Allows one to conveniently obtain and display information that.
Data Access Patterns. Motivation Most software systems require persistent data (i.e. data that persists between program executions). In general, distributing.
Towards Bboogle 3.0.0: a Technical Walkthrough Patricia Goldweic Sr. Software Engineer AR&T, Northwestern University Brian Nielsen Manager, Faculty Support.
Mobile Application Development with ANDROID Tejas Lagvankar UMBC 29 April 2009.
About me Yichuan Wang Android Basics Credit goes to Google and UMBC.
1 Section 6 Embedded SQL. 6-2 CA306 Embedded SQL Section Content 6.1Embedded SQL 6.2Java Database Connectivity 6.3Web Databases.
Your Interactive Guide to the Digital World Discovering Computers 2012.
ContentProviders. SQLite Database SQLite is a software library that implements aself- contained, serverless,zero- configuration,transactionalSQL database.
By Mihir Joshi Nikhil Dixit Limaye Pallavi Bhide Payal Godse.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
ANDROID CONTENT PROVIDERS Peter Liu School of ICT, Seneca College.
01. Introduction to Android Prof. Oum Saokosal Master of Engineering in Information Systems, South Korea
Content providers Accessing shared data in a uniform way 1Content providers.
Cosc 5/4730 Android Content Providers and Intents.
Data Storage: Part 4 (Content Providers). Content Providers Content providers allow the sharing of data between applications. Inter-process communication.
COMP 365 Android Development.  Manages access from a central database  Allows multiple applications to access the same data.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
1 Tradedoubler & Mobile Mobile web & app tracking technical overview.
Open Data Protocol * Han Wang 11/30/2012 *
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Android Storage. There are several options for storage of data with Android We can put data into a preferences file. We can put data into a ‘normal’ file.
CS 7: Introduction to Computer Programming Java and the Internet Sections ,2.1.
Android Security Model that Provide a Base Operating System Presented: Hayder Abdulhameed.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Application Layer Honolulu Community College Cisco Academy Training Center Semester 1 Version
Persistance Android. Adding Persistance SQL Refresher Understand how to create and migrate SQLLite database with android APIs. – Get all tasks – Add a.
World Wide Web “WWW”, "Web" or "W3". World Wide Web “WWW”, "Web" or "W3"
1 Web Servers (Chapter 21 – Pages( ) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture.
Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Web Server.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Android Programming Steve Ko Computer Sciences and Engineering University at Buffalo.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Ben - Gurion University Department Of Communication Systems Engineering DNS For Cell Phones Yoav Peer, Eugene Volchek Instructor: Dr. Chen Avin.
CHAPTER 9 File Storage Shared Preferences SQLite.
Exploring Networked Data and Data Stores Lesson 3.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
Introduction to Database Programming with Python Gary Stewart
Data Storage in Android Димитър Н. Димитров. Why talk about data? Why not 3D graphics or network connectivity? Data as fundamental term in computer science.
1. 2 The Address Book app provides convenient access to contact information that’s stored in a SQLite database on the device. You can: scroll through.
DEPTT. OF COMP. SC & APPLICATIONS
Android Application -Architecture.
Android Content Providers & SQLite
The Client-Server Model
RESTful Sevices Distributed Objects Presented by: Shivank Malik
What is WWW? The term WWW refers to the World Wide Web or simply the Web. The World Wide Web consists of all the public Web sites connected to the Internet.
E-commerce | WWW World Wide Web - Concepts
E-commerce | WWW World Wide Web - Concepts
Web App vs Mobile App.
Chapter 3: Windows7 Part 4.
Ch > 28.4.
Android Storage.
WEB API.
Chapter 4.
System And Application Software
Chapter 27 WWW and HTTP.
Application layer Lecture 7.
Application Development A Tutorial Driven Course
Introduction to World Wide Web
WCF Data Services and Silverlight
Presentation transcript:

ContentProviders

SQLite Database SQLite is a software library that implements aself- contained, serverless,zero- configuration,transactionalSQL database engine. SQLite is the most widely deployedSQL database engine in the world. The source code for SQLite is in thepublic domainself- containedserverlesszero- configurationtransactionalmost widely deployedpublic domain Unlike client–server database management systems, the SQLite engine has no standalone processes with which the application program communicatesclient–server processes

What is SQLite SQLite is an Open Source Database which is embedded into Android. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. In addition it requires only little memory at runtime (approx. 250 KByte).

Use in Mobile Devices Due to its small size, SQLite is well suited to embedded systems, and is also included in: Apple's iOS (where it is used for the SMS/MMS, Calendar, Call history and Contacts storage)iOS Symbian OS Nokia's MaemoMaemo Google's AndroidAndroid RIM's BlackBerryBlackBerry Linux Foundation's MeeGoMeeGo Palm's webOS [31]webOS [31] However, it is also suitable for desktop operating systems; Apple adopted it as an option in Mac OS X's Core Data API from the original implementation in Mac OS X 10.4 onwards, and also for administration of videos and songs on the iPhone.Mac OS XCore DataMac OS X 10.4 iPhone

DB design and Implementation Design and implement a database adapter class to manage database transactions (ToDoDBAdapter) Inside the adapter class,design and implement adatabase helperclass (toDoDBOpenHelper) to create tables and handles table upgrades Theadapterclass–publishes static database constants–and handles queries and includes methods for creating,opening,and closing the database Provides strongly typed methods for adding remove and updating items

SQLITE DATABASE APPLICATION 1)Open DB 2)Close DB 3)Insert and Remove objects In a type safe way DBAdatper Class That enbales you to talk to Sqlite database DBHelper Class Create Tables Upgrade tables DBHELPER Class tasks

Cursor Class Android uses the Cursor class as a return value for queries Think of the Cursor as a pointer to the resultset from a database query.Using Cursor enables android to more efficiently manage rows and columns as needed

ContentValues object We use ontentValues object to store key/value pairs,its put() method enables you to insert key with values of different datatypes. CreateEntry (name, ) function created by you in the activity returns the ID of the inserted row,that is why you fix its return types as a long,if en error occurs during the operation,it returns -1

SQLite in Android SQLite is available on every Android device. Using an SQLite database in Android does not require any database setup or administration. You only have to define the SQL statements for creating and updating the database. Afterwards the database is automatically managed for you by the Android platform.

Content Providers Content Providers share content with applications across application boundries,Example of built in Content Providers are Contacts,MediaStore,Settings and more

ContentProviders and sharing Data An SQLite database is private to the application which creates it. If you want to share data with other applications you can use a ContentProvider. A ContentProvider allows applications to access data. In most cases this data is stored in an SQlite database

Content Providers A ContentProvider can be used internally in an application to access data. If the data should be shared with another application a ContentProvider allows this. The access to a ContentProvider is done via an URI. The basis for the URI is defined in the declaration of the ContentProvider in the "AndroidManifest.xml" file via the android:authorities attribute. Many Android datasources, e.g. the contacts, are accessible via ContentProviders. Typically the implementing classes for a ContentProviders provide public constants for the URI's.

Uniform Resource Identifier A unifrom resource indentifier is a string of characters used to identify the name or a resource on the internet URIs enable interaction representation of resource over network using specific protocols A URI is defined by its syntax and associated protocols

REPRESENTATIONAL STATE TRANSFER(REST) REST is a style of software architecture for distributed hypermedia systemssu ch as WWW ●REST architecture consists of clients and servers ●Requests from clients and responses from servers are built around transfers of representations of resources ●A resource is any coherent and meaningfu lconcept that may addressed ●Arepresentation is a sequence of bits that capture s the state of a resource ●Architectures that comply with REST standards are called RESTfull

WHAT IS Content Provider A content provider is a wraper around datasoruce A SQLite is an example of a datasource that can be exposed as a Content Provider. A content provider is a REST-like abstraction.

What is Content Provider An SQLite database is private to the application which creates it. If you want to share data with other applications you can use a ContentProvider. A ContentProvider allows applications to access data. In most cases this data is stored in an SQlite database. A ContentProvider can be used internally in an application to access data. If the data should be shared with another application a ContentProvider allows this.

What is ContentProvider(continue) The access to a ContentProvider is done via an URI. The basis for the URI is defined in the declaration of the ContentProvider in the "AndroidManifest.xml" file via the android:authorities attribute. Many Android datasources, e.g. the contacts, are accessible via ContentProviders. Typically the implementing classes for a ContentProviders provide public constants for the URI's.

Saving and retreiving Data through URIs Saving and Retreiving data can be only done through URIs. URIs are translated to underlying data access mechanisms. Any application installed on the same device can use these URIs to manipulate the Data

Data Encapsulation vs Data Access It is conceptually easier to think content provider as Data Encapsulation Why?Because content providers require an data access mechnism(database or netowork connection )on top of which they run The most frequent data access mechanism is the SQLite database.

When to use Content Providers Only if you need to share some data among different applications. For internal Data access you can use  Preferences  Files  SQLite  Networks

Android Built in Content providers Several built-in providers are Browser,CallLog, Contacts, MediaStore,Settings These top-level providers are SQLite databases encapsulated as content providers Some of these databases have multiple tables: for example,Contacts has People, Phones, Photos, and Groups tables List of providers varies from Android OS to Android Os

Content Providers as web site

ContentProvider as Web Site  Each content provider registers it self on a device as a website  The registration is done with a string called authority.  Authority is similar to a domain name  Authority string is the basis of a set of URI s the content provider offers

Authority Registration Authority must be registered into the androidmanifest.xml file

Authority Registration

Content URIs

Data is retreived from a content provider by invoking a URI. Retreived data are set of row and columns in a Cursor object. All content URIs have the same general form Content://*/*/* Content://com.google.provider.NotePad/note s/12

Segments of Content URIs URI is content://com.google.provider.NotePad/notes /12 content://com.google.provider.NotePad/notes /12 is the authority string used to locate the provider in the provider registry. notes/12 is the path section specific to that provider Notes and 12 are path segments.

Segments of a Content URI It is the content providers responsibility to document and programmatically hanlde paths and segments. Convention – The first segment of the path points to a collection of objects (eg notes) – The second segment of the path points to a specific object in that collection(eg 12)

Content URIs Content providers provide REST like URLs to retrieve and manipulate the data.

Built in Content Providers content://contacts/people The URIs do not have fully qualified names because they are built in All third party content providers are recommended to have fully qulaified paths.

MIME Types

 A Web site returns a MIME type for a given URL A Browser starts a URL handling program depending on the URL's MIME type  MIME types work on Android in the same way they work in HTTP : a content provider can be asked for the MIME type of a given URI  When asked about the MIME type, the provider returns a two-part string according to the standard web MIME conventions

Data Access With URIs