IT. Expert System.

Android Reference

ContentResolver


android.content

Class ContentResolver

  • Direct Known Subclasses:
    MockContentResolver


    public abstract class ContentResolver
    extends Object
    This class provides applications access to the content model.

    Developer Guides

    For more information about using a ContentResolver with content providers, read the Content Providers developer guide.

    • Field Detail

      • SYNC_EXTRAS_IGNORE_SETTINGS

        public static final String SYNC_EXTRAS_IGNORE_SETTINGS
        If this extra is set to true then the sync settings (like getSyncAutomatically()) are ignored by the sync scheduler.
        See Also:
        Constant Field Values
      • SYNC_EXTRAS_IGNORE_BACKOFF

        public static final String SYNC_EXTRAS_IGNORE_BACKOFF
        If this extra is set to true then any backoffs for the initial attempt (e.g. due to retries) are ignored by the sync scheduler. If this request fails and gets rescheduled then the retries will still honor the backoff.
        See Also:
        Constant Field Values
      • SYNC_EXTRAS_DO_NOT_RETRY

        public static final String SYNC_EXTRAS_DO_NOT_RETRY
        If this extra is set to true then the request will not be retried if it fails.
        See Also:
        Constant Field Values
      • SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS

        public static final String SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS
        See Also:
        Constant Field Values
      • SYNC_EXTRAS_INITIALIZE

        public static final String SYNC_EXTRAS_INITIALIZE
        Set by the SyncManager to request that the SyncAdapter initialize itself for the given account/authority pair. One required initialization step is to ensure that setIsSyncable(android.accounts.Account, String, int) has been called with a >= 0 value. When this flag is set the SyncAdapter does not need to do a full sync, though it is allowed to do so.
        See Also:
        Constant Field Values
      • CURSOR_ITEM_BASE_TYPE

        public static final String CURSOR_ITEM_BASE_TYPE
        This is the Android platform's base MIME type for a content: URI containing a Cursor of a single item. Applications should use this as the base type along with their own sub-type of their content: URIs that represent a particular item. For example, hypothetical IMAP email client may have a URI content://com.company.provider.imap/inbox/1 for a particular message in the inbox, whose MIME type would be reported as CURSOR_ITEM_BASE_TYPE + "/vnd.company.imap-msg"

        Compare with CURSOR_DIR_BASE_TYPE.

        See Also:
        Constant Field Values
      • CURSOR_DIR_BASE_TYPE

        public static final String CURSOR_DIR_BASE_TYPE
        This is the Android platform's base MIME type for a content: URI containing a Cursor of zero or more items. Applications should use this as the base type along with their own sub-type of their content: URIs that represent a directory of items. For example, hypothetical IMAP email client may have a URI content://com.company.provider.imap/inbox for all of the messages in its inbox, whose MIME type would be reported as CURSOR_DIR_BASE_TYPE + "/vnd.company.imap-msg"

        Note how the base MIME type varies between this and CURSOR_ITEM_BASE_TYPE depending on whether there is one single item or multiple items in the data set, while the sub-type remains the same because in either case the data structure contained in the cursor is the same.

        See Also:
        Constant Field Values
      • SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS

        public static final int SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS
        See Also:
        Constant Field Values
      • SYNC_ERROR_AUTHENTICATION

        public static final int SYNC_ERROR_AUTHENTICATION
        See Also:
        Constant Field Values
      • SYNC_ERROR_TOO_MANY_DELETIONS

        public static final int SYNC_ERROR_TOO_MANY_DELETIONS
        See Also:
        Constant Field Values
      • SYNC_ERROR_TOO_MANY_RETRIES

        public static final int SYNC_ERROR_TOO_MANY_RETRIES
        See Also:
        Constant Field Values
      • SYNC_OBSERVER_TYPE_SETTINGS

        public static final int SYNC_OBSERVER_TYPE_SETTINGS
        See Also:
        Constant Field Values
      • SYNC_OBSERVER_TYPE_PENDING

        public static final int SYNC_OBSERVER_TYPE_PENDING
        See Also:
        Constant Field Values
      • SYNC_OBSERVER_TYPE_ACTIVE

        public static final int SYNC_OBSERVER_TYPE_ACTIVE
        See Also:
        Constant Field Values
      • SYNC_OBSERVER_TYPE_STATUS

        public static final int SYNC_OBSERVER_TYPE_STATUS
        See Also:
        Constant Field Values
    • Constructor Detail

      • ContentResolver

        public ContentResolver(Context context)
    • Method Detail

      • acquireExistingProvider

        protected IContentProvider acquireExistingProvider(Context c,
                                               String name)
        Providing a default implementation of this, to avoid having to change a lot of other things, but implementations of ContentResolver should implement it. @hide
      • releaseUnstableProvider

        public abstract boolean releaseUnstableProvider(IContentProvider icp)
      • unstableProviderDied

        public abstract void unstableProviderDied(IContentProvider icp)
      • getType

        public final String getType(Uri url)
        Return the MIME type of the given content URL.
        Parameters:
        url - A Uri identifying content (either a list or specific type), using the content:// scheme.
        Returns:
        A MIME type for the content, or null if the URL is invalid or the type is unknown
      • getStreamTypes

        public String[] getStreamTypes(Uri url,
                              String mimeTypeFilter)
        Query for the possible MIME types for the representations the given content URL can be returned when opened as as stream with openTypedAssetFileDescriptor(android.net.Uri, java.lang.String, android.os.Bundle). Note that the types here are not necessarily a superset of the type returned by getType(android.net.Uri) -- many content providers can not return a raw stream for the structured data that they contain.
        Parameters:
        url - A Uri identifying content (either a list or specific type), using the content:// scheme.
        mimeTypeFilter - The desired MIME type. This may be a pattern, such as *\/*, to query for all available MIME types that match the pattern.
        Returns:
        Returns an array of MIME type strings for all available data streams that match the given mimeTypeFilter. If there are none, null is returned.
      • query

        public final Cursor query(Uri uri,
                   String[] projection,
                   String selection,
                   String[] selectionArgs,
                   String sortOrder)

        Query the given URI, returning a Cursor over the result set.

        For best performance, the caller should follow these guidelines:

        • Provide an explicit projection, to prevent reading data from storage that aren't going to be used.
        • Use question mark parameter markers such as 'phone=?' instead of explicit values in the selection parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.

        Parameters:
        uri - The URI, using the content:// scheme, for the content to retrieve.
        projection - A list of which columns to return. Passing null will return all columns, which is inefficient.
        selection - A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI.
        selectionArgs - You may include ?s in selection, which will be replaced by the values from selectionArgs, in the order that they appear in the selection. The values will be bound as Strings.
        sortOrder - How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
        Returns:
        A Cursor object, which is positioned before the first entry, or null
        See Also:
        Cursor
      • query

        public final Cursor query(Uri uri,
                   String[] projection,
                   String selection,
                   String[] selectionArgs,
                   String sortOrder,
                   CancellationSignal cancellationSignal)

        Query the given URI, returning a Cursor over the result set.

        For best performance, the caller should follow these guidelines:

        • Provide an explicit projection, to prevent reading data from storage that aren't going to be used.
        • Use question mark parameter markers such as 'phone=?' instead of explicit values in the selection parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.

        Parameters:
        uri - The URI, using the content:// scheme, for the content to retrieve.
        projection - A list of which columns to return. Passing null will return all columns, which is inefficient.
        selection - A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI.
        selectionArgs - You may include ?s in selection, which will be replaced by the values from selectionArgs, in the order that they appear in the selection. The values will be bound as Strings.
        sortOrder - How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
        cancellationSignal - A signal to cancel the operation in progress, or null if none. If the operation is canceled, then OperationCanceledException will be thrown when the query is executed.
        Returns:
        A Cursor object, which is positioned before the first entry, or null
        See Also:
        Cursor
      • openAssetFileDescriptor

        public final AssetFileDescriptor openAssetFileDescriptor(Uri uri,
                                                  String mode)
                                                          throws FileNotFoundException
        Open a raw file descriptor to access data under a URI. This interacts with the underlying ContentProvider.openAssetFile(android.net.Uri, java.lang.String) method of the provider associated with the given URI, to retrieve any file stored there.
        Accepts the following URI schemes:
        The android.resource (SCHEME_ANDROID_RESOURCE) Scheme

        A Uri object can be used to reference a resource in an APK file. The Uri should be one of the following formats:

        • android.resource://package_name/id_number
          package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp
          id_number is the int form of the ID.
          The easiest way to construct this form is
          Uri uri = Uri.parse("android.resource://com.example.myapp/" + R.raw.my_resource");
        • android.resource://package_name/type/name
          package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp
          type is the string form of the resource type. For example, raw or drawable. name is the string form of the resource name. That is, whatever the file name was in your res directory, without the type extension. The easiest way to construct this form is
          Uri uri = Uri.parse("android.resource://com.example.myapp/raw/my_resource");

        Note that if this function is called for read-only input (mode is "r") on a content: URI, it will instead call openTypedAssetFileDescriptor(android.net.Uri, java.lang.String, android.os.Bundle) for you with a MIME type of "*\/*". This allows such callers to benefit from any built-in data conversion that a provider implements.

        Parameters:
        uri - The desired URI to open.
        mode - The file mode to use, as per ContentProvider.openAssetFile.
        Returns:
        Returns a new ParcelFileDescriptor pointing to the file. You own this descriptor and are responsible for closing it when done.
        Throws:
        FileNotFoundException - Throws FileNotFoundException of no file exists under the URI or the mode is invalid.
      • openTypedAssetFileDescriptor

        public final AssetFileDescriptor openTypedAssetFileDescriptor(Uri uri,
                                                       String mimeType,
                                                       Bundle opts)
                                                               throws FileNotFoundException
        Open a raw file descriptor to access (potentially type transformed) data from a "content:" URI. This interacts with the underlying ContentProvider.openTypedAssetFile(android.net.Uri, java.lang.String, android.os.Bundle) method of the provider associated with the given URI, to retrieve retrieve any appropriate data stream for the data stored there.

        Unlike openAssetFileDescriptor(android.net.Uri, java.lang.String), this function only works with "content:" URIs, because content providers are the only facility with an associated MIME type to ensure that the returned data stream is of the desired type.

        All text/* streams are encoded in UTF-8.

        Parameters:
        uri - The desired URI to open.
        mimeType - The desired MIME type of the returned data. This can be a pattern such as *\/*, which will allow the content provider to select a type, though there is no way for you to determine what type it is returning.
        opts - Additional provider-dependent options.
        Returns:
        Returns a new ParcelFileDescriptor from which you can read the data stream from the provider. Note that this may be a pipe, meaning you can't seek in it. The only seek you should do is if the AssetFileDescriptor contains an offset, to move to that offset before reading. You own this descriptor and are responsible for closing it when done.
        Throws:
        FileNotFoundException - Throws FileNotFoundException of no data of the desired type exists under the URI.
      • insert

        public final Uri insert(Uri url,
                 ContentValues values)
        Inserts a row into a table at the given URL. If the content provider supports transactions the insertion will be atomic.
        Parameters:
        url - The URL of the table to insert into.
        values - The initial values for the newly inserted row. The key is the column name for the field. Passing an empty ContentValues will create an empty row.
        Returns:
        the URL of the newly created row.
      • bulkInsert

        public final int bulkInsert(Uri url,
                     ContentValues[] values)
        Inserts multiple rows into a table at the given URL. This function make no guarantees about the atomicity of the insertions.
        Parameters:
        url - The URL of the table to insert into.
        values - The initial values for the newly inserted rows. The key is the column name for the field. Passing null will create an empty row.
        Returns:
        the number of newly created rows.
      • delete

        public final int delete(Uri url,
                 String where,
                 String[] selectionArgs)
        Deletes row(s) specified by a content URI. If the content provider supports transactions, the deletion will be atomic.
        Parameters:
        url - The URL of the row to delete.
        where - A filter to apply to rows before deleting, formatted as an SQL WHERE clause (excluding the WHERE itself).
        Returns:
        The number of rows deleted.
      • update

        public final int update(Uri uri,
                 ContentValues values,
                 String where,
                 String[] selectionArgs)
        Update row(s) in a content URI. If the content provider supports transactions the update will be atomic.
        Parameters:
        uri - The URI to modify.
        values - The new field values. The key is the column name for the field. A null value will remove an existing field value.
        where - A filter to apply to rows before updating, formatted as an SQL WHERE clause (excluding the WHERE itself).
        Returns:
        the number of rows updated.
        Throws:
        NullPointerException - if uri or values are null
      • call

        public final Bundle call(Uri uri,
                  String method,
                  String arg,
                  Bundle extras)
        Call a provider-defined method. This can be used to implement read or write interfaces which are cheaper than using a Cursor and/or do not fit into the traditional table model.
        Parameters:
        method - provider-defined method name to call. Opaque to framework, but must be non-null.
        arg - provider-defined String argument. May be null.
        extras - provider-defined Bundle argument. May be null.
        Returns:
        a result Bundle, possibly null. Will be null if the ContentProvider does not implement call.
        Throws:
        NullPointerException - if uri or method is null
        IllegalArgumentException - if uri is not known
      • acquireProvider

        public final IContentProvider acquireProvider(Uri uri)
        Returns the content provider for the given content URI.
        Parameters:
        uri - The URI to a content provider
        Returns:
        The ContentProvider for the given URI, or null if no content provider is found.
      • acquireExistingProvider

        public final IContentProvider acquireExistingProvider(Uri uri)
        Returns the content provider for the given content URI if the process already has a reference on it.
        Parameters:
        uri - The URI to a content provider
        Returns:
        The ContentProvider for the given URI, or null if no content provider is found.
      • acquireUnstableProvider

        public final IContentProvider acquireUnstableProvider(Uri uri)
        Returns the content provider for the given content URI.
        Parameters:
        uri - The URI to a content provider
        Returns:
        The ContentProvider for the given URI, or null if no content provider is found.
      • acquireContentProviderClient

        public final ContentProviderClient acquireContentProviderClient(Uri uri)
        Returns a ContentProviderClient that is associated with the ContentProvider that services the content at uri, starting the provider if necessary. Returns null if there is no provider associated wih the uri. The caller must indicate that they are done with the provider by calling ContentProviderClient.release() which will allow the system to release the provider it it determines that there is no other reason for keeping it active.
        Parameters:
        uri - specifies which provider should be acquired
        Returns:
        a ContentProviderClient that is associated with the ContentProvider that services the content at uri or null if there isn't one.
      • acquireContentProviderClient

        public final ContentProviderClient acquireContentProviderClient(String name)
        Returns a ContentProviderClient that is associated with the ContentProvider with the authority of name, starting the provider if necessary. Returns null if there is no provider associated wih the uri. The caller must indicate that they are done with the provider by calling ContentProviderClient.release() which will allow the system to release the provider it it determines that there is no other reason for keeping it active.
        Parameters:
        name - specifies which provider should be acquired
        Returns:
        a ContentProviderClient that is associated with the ContentProvider with the authority of name or null if there isn't one.
      • acquireUnstableContentProviderClient

        public final ContentProviderClient acquireUnstableContentProviderClient(Uri uri)
        Like acquireContentProviderClient(Uri), but for use when you do not trust the stability of the target content provider. This turns off the mechanism in the platform clean up processes that are dependent on a content provider if that content provider's process goes away. Normally you can safely assume that once you have acquired a provider, you can freely use it as needed and it won't disappear, even if your process is in the background. If using this method, you need to take care to deal with any failures when communicating with the provider, and be sure to close it so that it can be re-opened later. In particular, catching a DeadObjectException from the calls there will let you know that the content provider has gone away; at that point the current ContentProviderClient object is invalid, and you should release it. You can acquire a new one if you would like to try to restart the provider and perform new operations on it.
      • acquireUnstableContentProviderClient

        public final ContentProviderClient acquireUnstableContentProviderClient(String name)
        Like acquireContentProviderClient(String), but for use when you do not trust the stability of the target content provider. This turns off the mechanism in the platform clean up processes that are dependent on a content provider if that content provider's process goes away. Normally you can safely assume that once you have acquired a provider, you can freely use it as needed and it won't disappear, even if your process is in the background. If using this method, you need to take care to deal with any failures when communicating with the provider, and be sure to close it so that it can be re-opened later. In particular, catching a DeadObjectException from the calls there will let you know that the content provider has gone away; at that point the current ContentProviderClient object is invalid, and you should release it. You can acquire a new one if you would like to try to restart the provider and perform new operations on it.
      • registerContentObserver

        public final void registerContentObserver(Uri uri,
                                   boolean notifyForDescendents,
                                   ContentObserver observer)
        Register an observer class that gets callbacks when data identified by a given content URI changes.
        Parameters:
        uri - The URI to watch for changes. This can be a specific row URI, or a base URI for a whole class of content.
        notifyForDescendents - If true changes to URIs beginning with uri will also cause notifications to be sent. If false only changes to the exact URI specified by uri will cause notifications to be sent. If true, than any URI values at or below the specified URI will also trigger a match.
        observer - The object that receives callbacks when changes occur.
        See Also:
        unregisterContentObserver(android.database.ContentObserver)
      • registerContentObserver

        public final void registerContentObserver(Uri uri,
                                   boolean notifyForDescendents,
                                   ContentObserver observer,
                                   int userHandle)
      • notifyChange

        public void notifyChange(Uri uri,
                        ContentObserver observer)
        Notify registered observers that a row was updated and attempt to sync changes to the network. To register, call registerContentObserver(). By default, CursorAdapter objects will get this notification.
        Parameters:
        uri - The uri of the content that was changed.
        observer - The observer that originated the change, may be null. The observer that originated the change will only receive the notification if it has requested to receive self-change notifications by implementing ContentObserver.deliverSelfNotifications() to return true.
      • notifyChange

        public void notifyChange(Uri uri,
                        ContentObserver observer,
                        boolean syncToNetwork)
        Notify registered observers that a row was updated. To register, call registerContentObserver(). By default, CursorAdapter objects will get this notification. If syncToNetwork is true, this will attempt to schedule a local sync using the sync adapter that's registered for the authority of the provided uri. No account will be passed to the sync adapter, so all matching accounts will be synchronized.
        Parameters:
        uri - The uri of the content that was changed.
        observer - The observer that originated the change, may be null. The observer that originated the change will only receive the notification if it has requested to receive self-change notifications by implementing ContentObserver.deliverSelfNotifications() to return true.
        syncToNetwork - If true, attempt to sync the change to the network.
        See Also:
        requestSync(android.accounts.Account, String, android.os.Bundle)
      • notifyChange

        public void notifyChange(Uri uri,
                        ContentObserver observer,
                        boolean syncToNetwork,
                        int userHandle)
        Notify registered observers within the designated user(s) that a row was updated.
      • startSync

        @Deprecated
        public void startSync(Uri uri,
                                Bundle extras)
        Start an asynchronous sync operation. If you want to monitor the progress of the sync you may register a SyncObserver. Only values of the following types may be used in the extras bundle:
        • Integer
        • Long
        • Boolean
        • Float
        • Double
        • String
        Parameters:
        uri - the uri of the provider to sync or null to sync all providers.
        extras - any extras to pass to the SyncAdapter.
      • requestSync

        public static void requestSync(Account account,
                       String authority,
                       Bundle extras)
        Start an asynchronous sync operation. If you want to monitor the progress of the sync you may register a SyncObserver. Only values of the following types may be used in the extras bundle:
        • Integer
        • Long
        • Boolean
        • Float
        • Double
        • String
        Parameters:
        account - which account should be synced
        authority - which authority should be synced
        extras - any extras to pass to the SyncAdapter.
      • validateSyncExtrasBundle

        public static void validateSyncExtrasBundle(Bundle extras)
        Check that only values of the following types are in the Bundle:
        • Integer
        • Long
        • Boolean
        • Float
        • Double
        • String
        • Account
        • null
        Parameters:
        extras - the Bundle to check
      • cancelSync

        @Deprecated
        public void cancelSync(Uri uri)
        Cancel any active or pending syncs that match the Uri. If the uri is null then all syncs will be canceled.
        Parameters:
        uri - the uri of the provider to sync or null to sync all providers.
      • cancelSync

        public static void cancelSync(Account account,
                      String authority)
        Cancel any active or pending syncs that match account and authority. The account and authority can each independently be set to null, which means that syncs with any account or authority, respectively, will match.
        Parameters:
        account - filters the syncs that match by this account
        authority - filters the syncs that match by this authority
      • getSyncAdapterTypes

        public static SyncAdapterType[] getSyncAdapterTypes()
        Get information about the SyncAdapters that are known to the system.
        Returns:
        an array of SyncAdapters that have registered with the system
      • getSyncAutomatically

        public static boolean getSyncAutomatically(Account account,
                                   String authority)
        Check if the provider should be synced when a network tickle is received

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_SETTINGS.

        Parameters:
        account - the account whose setting we are querying
        authority - the provider whose setting we are querying
        Returns:
        true if the provider should be synced when a network tickle is received
      • setSyncAutomatically

        public static void setSyncAutomatically(Account account,
                                String authority,
                                boolean sync)
        Set whether or not the provider is synced when it receives a network tickle.

        This method requires the caller to hold the permission android.Manifest.permission#WRITE_SYNC_SETTINGS.

        Parameters:
        account - the account whose setting we are querying
        authority - the provider whose behavior is being controlled
        sync - true if the provider should be synced when tickles are received for it
      • addPeriodicSync

        public static void addPeriodicSync(Account account,
                           String authority,
                           Bundle extras,
                           long pollFrequency)
        Specifies that a sync should be requested with the specified the account, authority, and extras at the given frequency. If there is already another periodic sync scheduled with the account, authority and extras then a new periodic sync won't be added, instead the frequency of the previous one will be updated.

        These periodic syncs honor the "syncAutomatically" and "masterSyncAutomatically" settings. Although these sync are scheduled at the specified frequency, it may take longer for it to actually be started if other syncs are ahead of it in the sync operation queue. This means that the actual start time may drift.

        Periodic syncs are not allowed to have any of SYNC_EXTRAS_DO_NOT_RETRY, SYNC_EXTRAS_IGNORE_BACKOFF, SYNC_EXTRAS_IGNORE_SETTINGS, SYNC_EXTRAS_INITIALIZE, SYNC_EXTRAS_FORCE, SYNC_EXTRAS_EXPEDITED, SYNC_EXTRAS_MANUAL set to true. If any are supplied then an IllegalArgumentException will be thrown.

        This method requires the caller to hold the permission android.Manifest.permission#WRITE_SYNC_SETTINGS.

        Parameters:
        account - the account to specify in the sync
        authority - the provider to specify in the sync request
        extras - extra parameters to go along with the sync request
        pollFrequency - how frequently the sync should be performed, in seconds.
        Throws:
        IllegalArgumentException - if an illegal extra was set or if any of the parameters are null.
      • removePeriodicSync

        public static void removePeriodicSync(Account account,
                              String authority,
                              Bundle extras)
        Remove a periodic sync. Has no affect if account, authority and extras don't match an existing periodic sync.

        This method requires the caller to hold the permission android.Manifest.permission#WRITE_SYNC_SETTINGS.

        Parameters:
        account - the account of the periodic sync to remove
        authority - the provider of the periodic sync to remove
        extras - the extras of the periodic sync to remove
      • getPeriodicSyncs

        public static List<PeriodicSync> getPeriodicSyncs(Account account,
                                          String authority)
        Get the list of information about the periodic syncs for the given account and authority.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_SETTINGS.

        Parameters:
        account - the account whose periodic syncs we are querying
        authority - the provider whose periodic syncs we are querying
        Returns:
        a list of PeriodicSync objects. This list may be empty but will never be null.
      • getIsSyncable

        public static int getIsSyncable(Account account,
                        String authority)
        Check if this account/provider is syncable.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_SETTINGS.

        Returns:
        >0 if it is syncable, 0 if not, and <0 if the state isn't known yet.
      • setIsSyncable

        public static void setIsSyncable(Account account,
                         String authority,
                         int syncable)
        Set whether this account/provider is syncable.

        This method requires the caller to hold the permission android.Manifest.permission#WRITE_SYNC_SETTINGS.

        Parameters:
        syncable - >0 denotes syncable, 0 means not syncable, <0 means unknown
      • getMasterSyncAutomatically

        public static boolean getMasterSyncAutomatically()
        Gets the master auto-sync setting that applies to all the providers and accounts. If this is false then the per-provider auto-sync setting is ignored.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_SETTINGS.

        Returns:
        the master auto-sync setting that applies to all the providers and accounts
      • setMasterSyncAutomatically

        public static void setMasterSyncAutomatically(boolean sync)
        Sets the master auto-sync setting that applies to all the providers and accounts. If this is false then the per-provider auto-sync setting is ignored.

        This method requires the caller to hold the permission android.Manifest.permission#WRITE_SYNC_SETTINGS.

        Parameters:
        sync - the master auto-sync setting that applies to all the providers and accounts
      • isSyncActive

        public static boolean isSyncActive(Account account,
                           String authority)
        Returns true if there is currently a sync operation for the given account or authority in the pending list, or actively being processed.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_STATS.

        Parameters:
        account - the account whose setting we are querying
        authority - the provider whose behavior is being queried
        Returns:
        true if a sync is active for the given account or authority.
      • getCurrentSync

        @Deprecated
        public static SyncInfo getCurrentSync()
        Deprecated. Since multiple concurrent syncs are now supported you should use getCurrentSyncs() to get the accurate list of current syncs. This method returns the first item from the list of current syncs or null if there are none.
        If a sync is active returns the information about it, otherwise returns null.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_STATS.

        Returns:
        the SyncInfo for the currently active sync or null if one is not active.
      • getCurrentSyncs

        public static List<SyncInfo> getCurrentSyncs()
        Returns a list with information about all the active syncs. This list will be empty if there are no active syncs.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_STATS.

        Returns:
        a List of SyncInfo objects for the currently active syncs.
      • getSyncStatus

        public static SyncStatusInfo getSyncStatus(Account account,
                                   String authority)
        Returns the status that matches the authority.
        Parameters:
        account - the account whose setting we are querying
        authority - the provider whose behavior is being queried
        Returns:
        the SyncStatusInfo for the authority, or null if none exists
      • isSyncPending

        public static boolean isSyncPending(Account account,
                            String authority)
        Return true if the pending status is true of any matching authorities.

        This method requires the caller to hold the permission android.Manifest.permission#READ_SYNC_STATS.

        Parameters:
        account - the account whose setting we are querying
        authority - the provider whose behavior is being queried
        Returns:
        true if there is a pending sync with the matching account and authority
      • addStatusChangeListener

        public static Object addStatusChangeListener(int mask,
                                     SyncStatusObserver callback)
        Request notifications when the different aspects of the SyncManager change. The different items that can be requested are: The caller can set one or more of the status types in the mask for any given listener registration.
        Parameters:
        mask - the status change types that will cause the callback to be invoked
        callback - observer to be invoked when the status changes
        Returns:
        a handle that can be used to remove the listener at a later time
      • getContentService

        public static IContentService getContentService()


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 3358 / . Delta: 0.08052 с