Package org.robolectric.shadows
Class ShadowContentResolver
java.lang.Object
org.robolectric.shadows.ShadowContentResolver
@Implements(android.content.ContentResolver.class) public class ShadowContentResolver extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowContentResolver.DeleteStatement
A statement used to delete content in aContentProvider
.static class
ShadowContentResolver.InsertStatement
A statement used to insert content into aContentProvider
.static class
ShadowContentResolver.NotifiedUri
static class
ShadowContentResolver.Statement
A statement used to modify content in aContentProvider
.static class
ShadowContentResolver.Status
static class
ShadowContentResolver.UpdateStatement
A statement used to update content in aContentProvider
. -
Constructor Summary
Constructors Constructor Description ShadowContentResolver()
-
Method Summary
-
Constructor Details
-
ShadowContentResolver
public ShadowContentResolver()
-
-
Method Details
-
reset
-
registerInputStream
-
registerInputStreamSupplier
-
registerOutputStream
-
registerOutputStreamSupplier
-
openInputStream
-
openOutputStream
-
insert
If aContentProvider
is registered for the givenUri
, itsContentProvider.insert(Uri, ContentValues)
method will be invoked. Tests can verify that this method was called usinggetStatements()
orgetInsertStatements()
. If no appropriateContentProvider
is found, no action will be taken and aUri
including the incremented value set withsetNextDatabaseIdForInserts(int)
will returned. -
update
@Implementation protected int update(Uri uri, ContentValues values, String where, String[] selectionArgs)If aContentProvider
is registered for the givenUri
, itsContentProvider.update(Uri, ContentValues, String, String[])
method will be invoked. Tests can verify that this method was called usinggetStatements()
orgetUpdateStatements()
.- Returns:
- If no appropriate
ContentProvider
is found, no action will be taken and 1 will be returned.
-
query
@Implementation(minSdk=26) protected final Cursor query(Uri uri, String[] projection, Bundle queryArgs, CancellationSignal cancellationSignal) -
query
-
query
@Implementation protected Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) -
getType
-
call
-
acquireContentProviderClient
-
acquireContentProviderClient
-
acquireUnstableContentProviderClient
@Implementation protected final ContentProviderClient acquireUnstableContentProviderClient(String name) -
acquireUnstableContentProviderClient
@Implementation protected final ContentProviderClient acquireUnstableContentProviderClient(Uri uri) -
acquireProvider
-
acquireProvider
-
acquireUnstableProvider
-
acquireUnstableProvider
-
delete
If aContentProvider
is registered for the givenUri
, itsContentProvider.delete(Uri, String, String[])
method will be invoked. Tests can verify that this method was called usinggetDeleteStatements()
orgetDeletedUris()
. If no appropriateContentProvider
is found, no action will be taken and1
will be returned. -
bulkInsert
If aContentProvider
is registered for the givenUri
, itsContentProvider.bulkInsert(Uri, ContentValues[])
method will be invoked. Tests can verify that this method was called usinggetStatements()
orgetInsertStatements()
. If no appropriateContentProvider
is found, no action will be taken and the number of rows invalues
will be returned. -
notifyChange
@Implementation protected void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) -
notifyChange
-
applyBatch
@Implementation protected ContentProviderResult[] applyBatch(String authority, ArrayList<ContentProviderOperation> operations) throws OperationApplicationException- Throws:
OperationApplicationException
-
requestSync
@Implementation protected static void requestSync(Account account, String authority, Bundle extras) -
cancelSync
-
isSyncActive
-
setIsSyncable
@Implementation protected static void setIsSyncable(Account account, String authority, int syncable) -
getIsSyncable
-
getSyncAutomatically
-
setSyncAutomatically
@Implementation protected static void setSyncAutomatically(Account account, String authority, boolean sync) -
addPeriodicSync
@Implementation protected static void addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency) -
removePeriodicSync
@Implementation protected static void removePeriodicSync(Account account, String authority, Bundle extras) -
getPeriodicSyncs
@Implementation protected static List<PeriodicSync> getPeriodicSyncs(Account account, String authority) -
validateSyncExtrasBundle
-
setMasterSyncAutomatically
-
getMasterSyncAutomatically
-
takePersistableUriPermission
-
releasePersistableUriPermission
-
getPersistedUriPermissions
-
getProvider
-
registerProviderInternal
Internal-only method, do not use!Instead, use
ProviderInfo info = new ProviderInfo(); info.authority = authority; Robolectric.buildContentProvider(ContentProvider.class).create(info);
-
getStatus
-
getStatus
public static ShadowContentResolver.Status getStatus(Account account, String authority, boolean create)Retrieve information on the status of the given account.- Parameters:
account
- the accountauthority
- the authoritycreate
- whether to create if no such account is found- Returns:
- the account's status
-
setCursor
Deprecated.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
-
setCursor
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
-
setNextDatabaseIdForInserts
Deprecated.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
-
getStatements
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
Returns the list ofShadowContentResolver.InsertStatement
s,ShadowContentResolver.UpdateStatement
s, andShadowContentResolver.DeleteStatement
s invoked on thisContentResolver
.- Returns:
- a list of statements
-
getInsertStatements
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
Returns the list ofShadowContentResolver.InsertStatement
s for corresponding calls toContentResolver.insert(Uri, ContentValues)
orContentResolver.bulkInsert(Uri, ContentValues[])
.- Returns:
- a list of insert statements
-
getUpdateStatements
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
Returns the list ofShadowContentResolver.UpdateStatement
s for corresponding calls toContentResolver.update(Uri, ContentValues, String, String[])
.- Returns:
- a list of update statements
-
getDeletedUris
Deprecated. -
getDeleteStatements
Deprecated.Returns the list ofShadowContentResolver.DeleteStatement
s for corresponding calls toContentResolver.delete(Uri, String, String[])
.- Returns:
- a list of delete statements
-
getNotifiedUris
Deprecated. -
getContentProviderOperations
Deprecated. -
setContentProviderResult
Deprecated. -
setRegisterContentProviderException
MakesregisterContentObserver(android.net.Uri, boolean, android.database.ContentObserver)
throw the specified exception for the specified URI. -
clearRegisterContentProviderException
Clears an exception previously set withsetRegisterContentProviderException(Uri, RuntimeException)
. -
registerContentObserver
@Implementation protected void registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer) -
registerContentObserver
@Implementation(minSdk=17) protected void registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer, int userHandle) -
unregisterContentObserver
-
getSyncAdapterTypes
-
setSyncAdapterTypes
Sets the SyncAdapterType array which will be returned bygetSyncAdapterTypes()
. -
getContentObservers
Returns the content observers registered for updates under the given URI. Will be empty if no observer is registered.- Parameters:
uri
- Given URI- Returns:
- The content observers, or null
-
onDbCorruption
@Implementation(minSdk=29) protected static void onDbCorruption(String tag, String message, Throwable stacktrace)
-