Andriod App Summary - Study24x7
Social learning Network
study24x7

Default error msg

Login

New to Study24x7 ? Join Now
Already have an account? Login

Andriod App Summary

Updated on 10 February 2022
study24x7
Shivam Kumar
6 min read 3 views
Updated on 10 February 2022



A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider-client object. Together, providers and provider clients offer a consistent, standard interface to data that also handles inter-process communication and secure data access.

Typically you work with content providers in one of two scenarios; you may want to implement code to access an existing content provider in another application, or you may want to create a new content provider in your application to share data with other applications. This topic covers the basics of working with existing content providers. To learn more about implementing content providers in your own applications, see Creating a content provider.


This topic describes the following:

  1. How content providers work.
  2. The API you use to retrieve data from a content provider.
  3. The API you use to insert, update, or delete data in a content provider.
  4. Other API features that facilitate working with providers.




Overview

A content provider presents data to external applications as one or more tables that are similar to the tables found in a relational database. A row represents an instance of some type of data the provider collects, and each column in the row represents an individual piece of data collected for an instance.

A content provider coordinates access to the data storage layer in your application for a number of different APIs and components as illustrated in figure 1, these include:

  1. Sharing access to your application data with other applications
  2. Sending data to a widget
  3. Returning custom search suggestions for your application through the search framework using SearchRecentSuggestionsProvider
  4. Synchronizing application data with your server using an implementation of AbstractThreadedSyncAdapter
  5. Loading data in your UI using a CursorLoader

Relationship between content provider and other components.Figure 1. Relationship between the content provider and other components.







  1. Accessing a provider

When you want to access data in a content provider, you use the object in your applications 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. 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.

A common pattern for accessing a ContentProvider from your UI uses a CursorLoader to run an asynchronous query in the background. The Activity or Fragment in your UI call a CursorLoader to the query, which in turn gets the ContentProvider using the ContentResolver. This allows the UI to continue to be available to the user while the query is running. This pattern involves the interaction of a number of different objects, as well as the underlying storage mechanism, as illustrated in figure 2.

Interaction between ContentProvider, other classes, and storage.


Android app activities


Image result for android app content


Contains classes for accessing and publishing data on a device. It includes three main categories of APIs:

  1. Content sharing (android.content)
  2. For sharing content between application components. The most important classes are:
  3. ContentProvider and ContentResolver for managing and publishing persistent data associated with an application.
  4. Intent and IntentFilter, for delivering structured messages between different application components—allowing components to initiate other components and return results.
  5. Package management (android.content.pm)
  6. For accessing information about an Android package (an .apk), including information about its activities, permissions, services, signatures, and providers. The most important class for accessing this information is PackageManager.
  7. Resource management (android.content.res)
  8. For retrieving resource data associated with an application, such as strings, drawables, media, and device configuration details. The most important class for accessing this data is Resources.


Interface


ClipboardManager.OnPrimaryClipChangedListener

Defines a listener callback that is invoked when the primary clip on the clipboard changes. 

ComponentCallbacks

The set of callback APIs that are common to all application components (ActivityServiceContentProvider, and Application). 

ComponentCallbacks2

Extended ComponentCallbacks interface with a new callback for finer-grained memory management. 

ContentProvider.PipeDataWriter<T>

Interface to write a stream of data to a pipe. 

DialogInterface

The interface that defines a dialog-type class that can be shown, dismissed, or canceled, and may have buttons that can be clicked. 

DialogInterface.OnCancelListener

The interface used to allow the creator of a dialog to run some code when the dialog is canceled. 

DialogInterface.OnClickListener

The interface used to allow the creator of a dialog to run some code when an item on the dialog is clicked. 

DialogInterface.OnDismissListener

The interface used to allow the creator of a dialog to run some code when the dialog is dismissed. 

DialogInterface.OnKeyListener

Interface definition for a callback to be invoked when a key event is dispatched to this dialog. 

DialogInterface.OnMultiChoiceClickListener

The interface used to allow the creator of a dialog to run some code when an item in a multi-choice dialog is clicked. 

DialogInterface.OnShowListener

The interface used to allow the creator of a dialog to run some code when the dialog is shown. 

EntityIterator

A specialization of Iterator that allows iterating over a collection of Entity objects. 

IntentSender.OnFinished

Callback interface for discovering when a send operation has completed. 

Loader.OnLoadCanceledListener<D>

This interface was deprecated in API level 28. Use Loader.OnLoadCanceledListener 

Loader.OnLoadCompleteListener<D>

This interface was deprecated in API level 28. Use Loader.OnLoadCompleteListener 

ServiceConnection

Interface for monitoring the state of an application service. 

SharedPreferences

Interface for accessing and modifying preference data returned by Context#getSharedPreferences

SharedPreferences.Editor

The interface used for modifying values in a SharedPreferences object. 

SharedPreferences.OnSharedPreferenceChangeListener

Interface definition for a callback to be invoked when a shared preference is changed. 

SyncStatusObserver

 












  1. Classes


AbstractThreadedSyncAdapter

An abstract implementation of a SyncAdapter that spawns a thread to invoke a sync operation. 

AsyncQueryHandler

A helper class to help make handling asynchronous ContentResolver queries easier. 

AsyncQueryHandler.WorkerArgs

 

AsyncQueryHandler.WorkerHandler

 

AsyncTaskLoader<D>

This class was deprecated in API level 28. Use the Support Library AsyncTaskLoader 

BroadcastReceiver

Base class for code that receives and handles broadcast intents sent by Context.sendBroadcast(Intent)

BroadcastReceiver.PendingResult

State for a result that is pending for a broadcast receiver. 

ClipboardManager

Interface to the clipboard service, for placing and retrieving text in the global clipboard. 

ClipData

Representation of a clipped data on the clipboard. 

ClipData.Item

Description of a single item in a ClipData. 

ClipDescription

Meta-data describing the contents of a ClipData

ComponentName

The identifier for a specific application component (ActivityServiceBroadcastReceiver, or ContentProvider) that is available. 

ContentProvider

Content providers are one of the primary building blocks of Android applications, providing content to applications. 

ContentProvider.CallingIdentity

An opaque token representing the identity of an incoming IPC. 

ContentProviderClient

The public interface object used to interact with a specific ContentProvider

ContentProviderOperation

Represents a single operation to be performed as part of a batch of operations. 

ContentProviderOperation.Builder

Used to add parameters to a ContentProviderOperation

ContentProviderResult

Contains the result of the application of a ContentProviderOperation

ContentQueryMap

Caches the contents of a cursor into a Map of String->ContentValues and optionally keeps the cache fresh by registering for updates on the content backing the cursor. 

ContentResolver

This class provides applications access to the content model. 

ContentResolver.MimeTypeInfo

A detailed description of a specific MIME type, including an icon and label that describe the type. 

ContentUris

Utility methods useful for working with Uri objects that use the "content" (content://) scheme. 

ContentValues

This class is used to store a set of values that the ContentResolver can process. 

Context

Interface to global information about an application environment. 

ContextWrapper

Proxying implementation of Context that simply delegates all of its calls to another Context. 

CursorLoader

This class was deprecated in API level 28. Use the Support Library CursorLoader 

Entity

A representation of an item using ContentValues. 

Entity.NamedContentValues

 

Intent

An intent is an abstract description of an operation to be performed. 

Intent.FilterComparison

Wrapper class holding an Intent and implementing comparisons on it for the purpose of filtering. 

Intent.ShortcutIconResource

Represents a shortcut/live folder icon resource. 

IntentFilter

Structured description of Intent values to be matched. 

IntentFilter.AuthorityEntry

This is an entry for a single authority in the Iterator returned by IntentFilter.authoritiesIterator()

IntentSender

A description of an Intent and target action to perform with it. 

Loader<D>

This class was deprecated in API level 28. Use the Support Library Loader 

Loader.ForceLoadContentObserver

This class was deprecated in API level 28. Use Loader.ForceLoadContentObserver 

LocusId

An identifier for a unique state (locus) in the application. 

MutableContextWrapper

Special version of ContextWrapper that allows the base context to be modified after it is initially set. 

PeriodicSync

Value type that contains information about periodic sync. 

QuickViewConstants

Constants for Intent#ACTION_QUICK_VIEW

RestrictionEntry

Applications can expose restrictions for a restricted user on a multiuser device. 

RestrictionsManager

Provides a mechanism for apps to query restrictions imposed by an entity that manages the user. 

SearchRecentSuggestionsProvider

This superclass can be used to create a simple search suggestions provider for your application. 

SyncAdapterType

Value type that represents a SyncAdapterType. 

SyncContext

 

SyncInfo

Information about the sync operation that is currently underway. 

SyncRequest

Convenience class to construct sync requests. 

SyncRequest.Builder

Builder class for a SyncRequest

SyncResult

This class is used to communicate the results of a sync operation to the SyncManager. 

SyncStats

Used to record various statistics about the result of a sync operation. 

UriMatcher

Utility class to aid in matching URIs in content providers. 

UriPermission

Description of a single Uri permission grant. 




























Exceptions


ActivityNotFoundException

This exception is thrown when a call to Context#startActivity or one of its variants fails because an Activity can not be found to execute the given Intent. 

IntentFilter.MalformedMimeTypeException

This exception is thrown when a given MIME type does not have valid syntax. 

IntentSender.SendIntentException

Exception is thrown when trying to send through a PendingIntent that has been canceled or is otherwise no longer able to execute the request. 

OperationApplicationException

Thrown when an application of a ContentProviderOperation fails due to the specified constraints. 

ReceiverCallNotAllowedException

This exception is thrown from Context#registerReceiver and Context#bindService when these methods are being used from an BroadcastReceiver component. 






study24x7
Write a comment...
Related Posts