Compartilhar via


MockContentResolver Class

Definition

An extension of android.content.ContentResolver that is designed for testing.

[Android.Runtime.Register("android/test/mock/MockContentResolver", DoNotGenerateAcw=true)]
public class MockContentResolver : Android.Content.ContentResolver
[<Android.Runtime.Register("android/test/mock/MockContentResolver", DoNotGenerateAcw=true)>]
type MockContentResolver = class
    inherit ContentResolver
Inheritance
MockContentResolver
Attributes

Remarks

An extension of android.content.ContentResolver that is designed for testing.

MockContentResolver overrides Android's normal way of resolving providers by authority. To have access to a provider based on its authority, users of MockContentResolver first instantiate the provider and use MockContentResolver#addProvider(String, ContentProvider). Resolution of an authority occurs entirely within MockContentResolver.

Users can also set an authority's entry in the map to null, so that a provider is completely mocked out.

<div class="special reference"> <h3>Developer Guides</h3>

For more information about application testing, read the Testing developer guide.

</div>

Java documentation for android.test.mock.MockContentResolver.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

MockContentResolver()

Creates a local map of providers.

MockContentResolver(Context)

Creates a local map of providers.

MockContentResolver(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

AnyCursorItemType

This is the Android platform's generic MIME type to match any MIME type of the form "#CURSOR_ITEM_BASE_TYPE/SUB_TYPE".

(Inherited from ContentResolver)
CursorDirBaseType

This is the Android platform's base MIME type for a content: URI containing a Cursor of zero or more items.

(Inherited from ContentResolver)
CursorItemBaseType

This is the Android platform's base MIME type for a content: URI containing a Cursor of a single item.

(Inherited from ContentResolver)
ExtraHonoredArgs

Allows provider to report back to client which query keys are honored in a Cursor.

(Inherited from ContentResolver)
ExtraRefreshSupported

An extra boolean describing whether a particular provider supports refresh or not.

(Inherited from ContentResolver)
ExtraSize

An extra Point describing the optimal size for a requested image resource, in pixels.

(Inherited from ContentResolver)
ExtraTotalCount

Added to Cursor extras Bundle to indicate total row count of recordset when paging is supported.

(Inherited from ContentResolver)
NotifyDelete
Obsolete.

Flag for #notifyChange(Uri, ContentObserver, int): typically set by a ContentProvider to indicate that this notification is the result of a ContentProvider#delete call.

(Inherited from ContentResolver)
NotifyInsert
Obsolete.

Flag for #notifyChange(Uri, ContentObserver, int): typically set by a ContentProvider to indicate that this notification is the result of an ContentProvider#insert call.

(Inherited from ContentResolver)
NotifySkipNotifyForDescendants
Obsolete.

Flag for #notifyChange(Uri, ContentObserver, int): if set, this notification will be skipped if it is being delivered to the root URI of a ContentObserver that is using "notify for descendants.

(Inherited from ContentResolver)
NotifySyncToNetwork
Obsolete.

Flag for #notifyChange(Uri, ContentObserver, int): attempt to sync the change to the network.

(Inherited from ContentResolver)
NotifyUpdate
Obsolete.

Flag for #notifyChange(Uri, ContentObserver, int): typically set by a ContentProvider to indicate that this notification is the result of an ContentProvider#update call.

(Inherited from ContentResolver)
QueryArgGroupColumns

Specifies the list of columns (stored as a String[]) against which to group results.

(Inherited from ContentResolver)
QueryArgLimit

Specifies the max number of rows to include in a Cursor.

(Inherited from ContentResolver)
QueryArgOffset

Specifies the offset row index within a Cursor.

(Inherited from ContentResolver)
QueryArgSortCollation

Allows client to specify a hint to the provider declaring which collation to use when sorting values.

(Inherited from ContentResolver)
QueryArgSortColumns

Specifies the list of columns (stored as a String[]) against which to sort results.

(Inherited from ContentResolver)
QueryArgSortDirection

Specifies desired sort order.

(Inherited from ContentResolver)
QueryArgSortLocale

Allows client to specify a hint to the provider declaring which locale to use when sorting values.

(Inherited from ContentResolver)
QueryArgSqlGroupBy

Key for an SQL style GROUP BY string that may be present in the query Bundle argument passed to ContentProvider#query(Uri, String[], Bundle, CancellationSignal).

(Inherited from ContentResolver)
QueryArgSqlHaving

Key for an SQL style HAVING string that may be present in the query Bundle argument passed to ContentProvider#query(Uri, String[], Bundle, CancellationSignal).

(Inherited from ContentResolver)
QueryArgSqlLimit

Key for an SQL style LIMIT string that may be present in the query Bundle argument passed to ContentProvider#query(Uri, String[], Bundle, CancellationSignal).

(Inherited from ContentResolver)
QueryArgSqlSelection

Key for an SQL style selection string that may be present in the query Bundle argument passed to ContentProvider#query(Uri, String[], Bundle, CancellationSignal) when called by a legacy client.

(Inherited from ContentResolver)
QueryArgSqlSelectionArgs

Key for SQL selection string arguments list.

(Inherited from ContentResolver)
QueryArgSqlSortOrder

Key for an SQL style sort string that may be present in the query Bundle argument passed to ContentProvider#query(Uri, String[], Bundle, CancellationSignal) when called by a legacy client.

(Inherited from ContentResolver)
QuerySortDirectionAscending
Obsolete.
(Inherited from ContentResolver)
QuerySortDirectionDescending
Obsolete.
(Inherited from ContentResolver)
SchemeAndroidResource (Inherited from ContentResolver)
SchemeContent (Inherited from ContentResolver)
SchemeFile (Inherited from ContentResolver)
SyncExtrasAccount
Obsolete.

This member is deprecated.

(Inherited from ContentResolver)
SyncExtrasDiscardLocalDeletions

Indicates that the sync adapter should not proceed with the delete operations, if it determines that there are too many.

(Inherited from ContentResolver)
SyncExtrasDoNotRetry

If this extra is set to true then the request will not be retried if it fails.

(Inherited from ContentResolver)
SyncExtrasExpedited

If this extra is set to true, the sync request will be scheduled at the front of the sync request queue, but it is still subject to JobScheduler quota and throttling due to App Standby buckets.

(Inherited from ContentResolver)
SyncExtrasForce
Obsolete.

This member is deprecated.

(Inherited from ContentResolver)
SyncExtrasIgnoreBackoff

If this extra is set to true then any backoffs for the initial attempt (e.

(Inherited from ContentResolver)
SyncExtrasIgnoreSettings

If this extra is set to true then the sync settings (like getSyncAutomatically()) are ignored by the sync scheduler.

(Inherited from ContentResolver)
SyncExtrasInitialize

Set by the SyncManager to request that the SyncAdapter initialize itself for the given account/authority pair.

(Inherited from ContentResolver)
SyncExtrasManual

Setting this extra is the equivalent of setting both #SYNC_EXTRAS_IGNORE_SETTINGS and #SYNC_EXTRAS_IGNORE_BACKOFF

(Inherited from ContentResolver)
SyncExtrasOverrideTooManyDeletions

Indicates that the sync adapter should proceed with the delete operations, even if it determines that there are too many.

(Inherited from ContentResolver)
SyncExtrasRequireCharging

If this extra is set to true, the sync request will be scheduled only when the device is plugged in.

(Inherited from ContentResolver)
SyncExtrasScheduleAsExpeditedJob

Run this sync operation as an "expedited job" (see android.app.job.JobInfo.Builder#setExpedited(boolean)).

(Inherited from ContentResolver)
SyncExtrasUpload

Indicates that this sync is intended to only upload local changes to the server.

(Inherited from ContentResolver)
SyncObserverTypeActive
Obsolete.
(Inherited from ContentResolver)
SyncObserverTypePending
Obsolete.
(Inherited from ContentResolver)
SyncObserverTypeSettings
Obsolete.
(Inherited from ContentResolver)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
OutgoingPersistedUriPermissions

Return list of all persisted URI permission grants that are hosted by the calling app.

(Inherited from ContentResolver)
PeerReference (Inherited from Object)
PersistedUriPermissions

Return list of all URI permission grants that have been persisted by the calling app.

(Inherited from ContentResolver)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AcquireContentProviderClient(String)

Returns a ContentProviderClient that is associated with the ContentProvider with the authority of name, starting the provider if necessary.

(Inherited from ContentResolver)
AcquireContentProviderClient(Uri)

Returns a ContentProviderClient that is associated with the ContentProvider that services the content at uri, starting the provider if necessary.

(Inherited from ContentResolver)
AcquireUnstableContentProviderClient(String)

Like #acquireContentProviderClient(String), but for use when you do not trust the stability of the target content provider.

(Inherited from ContentResolver)
AcquireUnstableContentProviderClient(Uri)

Like #acquireContentProviderClient(Uri), but for use when you do not trust the stability of the target content provider.

(Inherited from ContentResolver)
AddProvider(String, ContentProvider)

Adds access to a provider based on its authority

ApplyBatch(String, IList<ContentProviderOperation>)

Applies each of the ContentProviderOperation objects and returns an array of their results.

(Inherited from ContentResolver)
BulkInsert(Uri, ContentValues[])

Inserts multiple rows into a table at the given URL.

(Inherited from ContentResolver)
Call(String, String, String, Bundle)

Call a provider-defined method.

(Inherited from ContentResolver)
Call(Uri, String, String, Bundle)

Call a provider-defined method.

(Inherited from ContentResolver)
CancelSync(Uri)
Obsolete.

Cancel any active or pending syncs that match the Uri.

(Inherited from ContentResolver)
Canonicalize(Uri)

Transform the given <var>url</var> to a canonical representation of its referenced resource, which can be used across devices, persisted, backed up and restored, etc.

(Inherited from ContentResolver)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Delete(Uri, Bundle)

Deletes row(s) specified by a content URI.

(Inherited from ContentResolver)
Delete(Uri, String, String[])

Deletes row(s) specified by a content URI.

(Inherited from ContentResolver)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetStreamTypes(Uri, String)

Query for the possible MIME types for the representations the given content URL can be returned when opened as as stream with #openTypedAssetFileDescriptor.

(Inherited from ContentResolver)
GetType(Uri)

Return the MIME type of the given content URL.

(Inherited from ContentResolver)
GetTypeInfo(String)

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

(Inherited from ContentResolver)
Insert(Uri, ContentValues, Bundle)

Inserts a row into a table at the given URL.

(Inherited from ContentResolver)
Insert(Uri, ContentValues)

Inserts a row into a table at the given URL.

(Inherited from ContentResolver)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LoadThumbnail(Uri, Size, CancellationSignal)

Convenience method that efficiently loads a visual thumbnail for the given Uri.

(Inherited from ContentResolver)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
NotifyChange(ICollection<Uri>, ContentObserver, NotifyChangeFlags)

Notify registered observers that several rows have been updated.

(Inherited from ContentResolver)
NotifyChange(Uri, ContentObserver, Boolean)

Notify registered observers that a row was updated.

(Inherited from ContentResolver)
NotifyChange(Uri, ContentObserver, NotifyChangeFlags)

Notify registered observers that a row was updated.

(Inherited from ContentResolver)
NotifyChange(Uri, ContentObserver)

Notify registered observers that a row was updated and attempt to sync changes to the network.

(Inherited from ContentResolver)
OpenAssetFile(Uri, String, CancellationSignal) (Inherited from ContentResolver)
OpenAssetFileDescriptor(Uri, String, CancellationSignal)

Open a raw file descriptor to access data under a URI.

(Inherited from ContentResolver)
OpenAssetFileDescriptor(Uri, String)

Open a raw file descriptor to access data under a URI.

(Inherited from ContentResolver)
OpenFile(Uri, String, CancellationSignal) (Inherited from ContentResolver)
OpenFileDescriptor(Uri, String, CancellationSignal)

Open a raw file descriptor to access data under a URI.

(Inherited from ContentResolver)
OpenFileDescriptor(Uri, String)

Open a raw file descriptor to access data under a URI.

(Inherited from ContentResolver)
OpenInputStream(Uri)

Open a stream on to the content associated with a content URI.

(Inherited from ContentResolver)
OpenOutputStream(Uri, String)

Open a stream on to the content associated with a content URI.

(Inherited from ContentResolver)
OpenOutputStream(Uri)

Synonym for #openOutputStream(Uri, String) openOutputStream(uri, "w").

(Inherited from ContentResolver)
OpenTypedAssetFile(Uri, String, Bundle, CancellationSignal) (Inherited from ContentResolver)
OpenTypedAssetFileDescriptor(Uri, String, Bundle, CancellationSignal)

Open a raw file descriptor to access (potentially type transformed) data from a "content:" URI.

(Inherited from ContentResolver)
OpenTypedAssetFileDescriptor(Uri, String, Bundle)

Open a raw file descriptor to access (potentially type transformed) data from a "content:" URI.

(Inherited from ContentResolver)
Query(Uri, String[], Bundle, CancellationSignal)

Query the given URI, returning a Cursor over the result set with support for cancellation.

(Inherited from ContentResolver)
Query(Uri, String[], String, String[], String, CancellationSignal)

Query the given URI, returning a Cursor over the result set with optional support for cancellation.

(Inherited from ContentResolver)
Query(Uri, String[], String, String[], String)

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

(Inherited from ContentResolver)
Refresh(Uri, Bundle, CancellationSignal)

This allows clients to request an explicit refresh of content identified by uri.

(Inherited from ContentResolver)
RegisterContentObserver(Uri, Boolean, ContentObserver)

Register an observer class that gets callbacks when data identified by a given content URI changes.

(Inherited from ContentResolver)
ReleasePersistableUriPermission(Uri, ActivityFlags)

Relinquish a persisted URI permission grant.

(Inherited from ContentResolver)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
StartSync(Uri, Bundle)
Obsolete.

Start an asynchronous sync operation.

(Inherited from ContentResolver)
TakePersistableUriPermission(Uri, ActivityFlags)

Take a persistable URI permission grant that has been offered.

(Inherited from ContentResolver)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Uncanonicalize(Uri)

Given a canonical Uri previously generated by #canonicalize, convert it to its local non-canonical form.

(Inherited from ContentResolver)
UnregisterContentObserver(ContentObserver)

Unregisters a change observer.

(Inherited from ContentResolver)
UnregisterFromRuntime() (Inherited from Object)
Update(Uri, ContentValues, Bundle)

Update row(s) in a content URI.

(Inherited from ContentResolver)
Update(Uri, ContentValues, String, String[])

Update row(s) in a content URI.

(Inherited from ContentResolver)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to