@Implements(android.content.ContentResolver.class) public class ShadowContentResolver extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
ShadowContentResolver.DeleteStatement |
A statement used to delete content in a
ContentProvider . |
static class |
ShadowContentResolver.InsertStatement |
A statement used to insert content into a
ContentProvider . |
static class |
ShadowContentResolver.NotifiedUri |
|
static class |
ShadowContentResolver.Statement |
A statement used to modify content in a
ContentProvider . |
static class |
ShadowContentResolver.Status |
|
static class |
ShadowContentResolver.UpdateStatement |
A statement used to update content in a
ContentProvider . |
Constructor | Description |
---|---|
ShadowContentResolver() |
@Resetter public static void reset()
public void registerInputStream(Uri uri, InputStream inputStream)
public void registerInputStreamSupplier(Uri uri, Supplier<InputStream> supplier)
public void registerOutputStream(Uri uri, OutputStream outputStream)
public void registerOutputStreamSupplier(Uri uri, Supplier<OutputStream> supplier)
@Implementation protected final InputStream openInputStream(Uri uri)
@Implementation protected final OutputStream openOutputStream(Uri uri)
@Implementation protected final Uri insert(Uri url, ContentValues values)
ContentProvider
is registered for the given Uri
, its ContentProvider.insert(Uri, ContentValues)
method will be invoked.
Tests can verify that this method was called using getStatements()
or getInsertStatements()
.
If no appropriate ContentProvider
is found, no action will be taken and a Uri
including the incremented value set with setNextDatabaseIdForInserts(int)
will
returned.@Implementation protected int update(Uri uri, ContentValues values, String where, String[] selectionArgs)
ContentProvider
is registered for the given Uri
, its ContentProvider.update(Uri, ContentValues, String, String[])
method will be invoked.
Tests can verify that this method was called using getStatements()
or getUpdateStatements()
.ContentProvider
is found, no action will be taken and 1 will
be returned.@Implementation(minSdk=26) protected final Cursor query(Uri uri, String[] projection, Bundle queryArgs, CancellationSignal cancellationSignal)
@Implementation protected final Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
@Implementation protected Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal)
@Implementation protected String getType(Uri uri)
@Implementation protected final ContentProviderClient acquireContentProviderClient(String name)
@Implementation protected final ContentProviderClient acquireContentProviderClient(Uri uri)
@Implementation protected final ContentProviderClient acquireUnstableContentProviderClient(String name)
@Implementation protected final ContentProviderClient acquireUnstableContentProviderClient(Uri uri)
@Implementation protected final IContentProvider acquireProvider(String name)
@Implementation protected final IContentProvider acquireProvider(Uri uri)
@Implementation protected final IContentProvider acquireUnstableProvider(String name)
@Implementation protected final IContentProvider acquireUnstableProvider(Uri uri)
@Implementation protected final int delete(Uri url, String where, String[] selectionArgs)
ContentProvider
is registered for the given Uri
, its ContentProvider.delete(Uri, String, String[])
method will be invoked.
Tests can verify that this method was called using getDeleteStatements()
or getDeletedUris()
.
If no appropriate ContentProvider
is found, no action will be taken and 1
will be returned.@Implementation protected final int bulkInsert(Uri url, ContentValues[] values)
ContentProvider
is registered for the given Uri
, its ContentProvider.bulkInsert(Uri, ContentValues[])
method will be invoked.
Tests can verify that this method was called using getStatements()
or getInsertStatements()
.
If no appropriate ContentProvider
is found, no action will be taken and the number
of rows in values
will be returned.@Implementation protected void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork)
@Implementation protected void notifyChange(Uri uri, ContentObserver observer)
@Implementation protected ContentProviderResult[] applyBatch(String authority, ArrayList<ContentProviderOperation> operations) throws OperationApplicationException
OperationApplicationException
@Implementation protected static void requestSync(Account account, String authority, Bundle extras)
@Implementation protected static void cancelSync(Account account, String authority)
@Implementation protected static boolean isSyncActive(Account account, String authority)
@Implementation protected static void setIsSyncable(Account account, String authority, int syncable)
@Implementation protected static int getIsSyncable(Account account, String authority)
@Implementation protected static boolean getSyncAutomatically(Account account, String authority)
@Implementation protected static void setSyncAutomatically(Account account, String authority, boolean sync)
@Implementation protected static void addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency)
@Implementation protected static void removePeriodicSync(Account account, String authority, Bundle extras)
@Implementation protected static List<PeriodicSync> getPeriodicSyncs(Account account, String authority)
@Implementation protected static void validateSyncExtrasBundle(Bundle extras)
@Implementation protected static void setMasterSyncAutomatically(boolean sync)
@Implementation protected static boolean getMasterSyncAutomatically()
@Implementation(minSdk=19) protected void takePersistableUriPermission(Uri uri, int modeFlags)
@Implementation(minSdk=19) protected void releasePersistableUriPermission(Uri uri, int modeFlags)
@Implementation(minSdk=19) protected List<UriPermission> getPersistedUriPermissions()
public static ContentProvider getProvider(Uri uri)
public static void registerProviderInternal(String authority, ContentProvider provider)
Instead, use
ProviderInfo info = new ProviderInfo(); info.authority = authority; Robolectric.buildContentProvider(ContentProvider.class).create(info);
public static ShadowContentResolver.Status getStatus(Account account, String authority)
public static ShadowContentResolver.Status getStatus(Account account, String authority, boolean create)
account
- the accountauthority
- the authoritycreate
- whether to create if no such account is found@Deprecated public void setCursor(BaseCursor cursor)
ContentResolver.acquireContentProviderClient(android.net.Uri)
@Deprecated public void setCursor(Uri uri, BaseCursor cursorForUri)
ContentResolver.acquireContentProviderClient(android.net.Uri)
@Deprecated public void setNextDatabaseIdForInserts(int nextId)
ContentResolver.acquireContentProviderClient(android.net.Uri)
@Deprecated public List<ShadowContentResolver.Statement> getStatements()
ContentResolver.acquireContentProviderClient(android.net.Uri)
ShadowContentResolver.InsertStatement
s, ShadowContentResolver.UpdateStatement
s, and ShadowContentResolver.DeleteStatement
s invoked on this ContentResolver
.@Deprecated public List<ShadowContentResolver.InsertStatement> getInsertStatements()
ContentResolver.acquireContentProviderClient(android.net.Uri)
ShadowContentResolver.InsertStatement
s for corresponding calls to ContentResolver.insert(Uri, ContentValues)
or ContentResolver.bulkInsert(Uri,
ContentValues[])
.@Deprecated public List<ShadowContentResolver.UpdateStatement> getUpdateStatements()
ContentResolver.acquireContentProviderClient(android.net.Uri)
ShadowContentResolver.UpdateStatement
s for corresponding calls to ContentResolver.update(Uri, ContentValues, String, String[])
.@Deprecated public List<Uri> getDeletedUris()
@Deprecated public List<ShadowContentResolver.DeleteStatement> getDeleteStatements()
ShadowContentResolver.DeleteStatement
s for corresponding calls to ContentResolver.delete(Uri, String, String[])
.@Deprecated public List<ShadowContentResolver.NotifiedUri> getNotifiedUris()
@Deprecated public List<ContentProviderOperation> getContentProviderOperations(String authority)
@Deprecated public void setContentProviderResult(ContentProviderResult[] contentProviderResults)
public void setRegisterContentProviderException(Uri uri, RuntimeException exception)
registerContentObserver(android.net.Uri, boolean, android.database.ContentObserver)
throw the specified exception for the specified URI.public void clearRegisterContentProviderException(Uri uri)
setRegisterContentProviderException(Uri,
RuntimeException)
.@Implementation protected void registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer)
@Implementation(minSdk=17) protected void registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer, int userHandle)
@Implementation protected void unregisterContentObserver(ContentObserver observer)
@Implementation protected static SyncAdapterType[] getSyncAdapterTypes()
public static void setSyncAdapterTypes(SyncAdapterType[] syncAdapterTypes)
getSyncAdapterTypes()
.public Collection<ContentObserver> getContentObservers(Uri uri)
uri
- Given URI