Package org.robolectric.shadows
Class ShadowContentResolver
- java.lang.Object
-
- org.robolectric.shadows.ShadowContentResolver
-
@Implements(android.content.ContentResolver.class) public class ShadowContentResolver extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowContentResolver.DeleteStatementA statement used to delete content in aContentProvider.static classShadowContentResolver.InsertStatementA statement used to insert content into aContentProvider.static classShadowContentResolver.NotifiedUristatic classShadowContentResolver.StatementA statement used to modify content in aContentProvider.static classShadowContentResolver.Statusstatic classShadowContentResolver.UpdateStatementA statement used to update content in aContentProvider.
-
Constructor Summary
Constructors Constructor Description ShadowContentResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected android.content.ContentProviderClientacquireContentProviderClient(android.net.Uri uri)protected android.content.ContentProviderClientacquireContentProviderClient(java.lang.String name)protected android.content.IContentProvideracquireProvider(android.net.Uri uri)protected android.content.IContentProvideracquireProvider(java.lang.String name)protected android.content.ContentProviderClientacquireUnstableContentProviderClient(android.net.Uri uri)protected android.content.ContentProviderClientacquireUnstableContentProviderClient(java.lang.String name)protected android.content.IContentProvideracquireUnstableProvider(android.net.Uri uri)protected android.content.IContentProvideracquireUnstableProvider(java.lang.String name)protected static voidaddPeriodicSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras, long pollFrequency)protected android.content.ContentProviderResult[]applyBatch(java.lang.String authority, java.util.ArrayList<android.content.ContentProviderOperation> operations)protected intbulkInsert(android.net.Uri url, android.content.ContentValues[] values)If aContentProvideris registered for the givenUri, itsContentProvider.bulkInsert(Uri, ContentValues[])method will be invoked.protected android.os.Bundlecall(android.net.Uri uri, java.lang.String method, java.lang.String arg, android.os.Bundle extras)protected static voidcancelSync(android.accounts.Account account, java.lang.String authority)voidclearRegisterContentProviderException(android.net.Uri uri)Clears an exception previously set withsetRegisterContentProviderException(Uri, RuntimeException).protected intdelete(android.net.Uri url, java.lang.String where, java.lang.String[] selectionArgs)If aContentProvideris registered for the givenUri, itsContentProvider.delete(Uri, String, String[])method will be invoked.java.util.Collection<android.database.ContentObserver>getContentObservers(android.net.Uri uri)Returns the content observers registered for updates under the given URI.java.util.List<android.content.ContentProviderOperation>getContentProviderOperations(java.lang.String authority)Deprecated.java.util.List<android.net.Uri>getDeletedUris()Deprecated.java.util.List<ShadowContentResolver.DeleteStatement>getDeleteStatements()Deprecated.java.util.List<ShadowContentResolver.InsertStatement>getInsertStatements()Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)protected static intgetIsSyncable(android.accounts.Account account, java.lang.String authority)protected static booleangetMasterSyncAutomatically()java.util.List<ShadowContentResolver.NotifiedUri>getNotifiedUris()Deprecated.protected static java.util.List<android.content.PeriodicSync>getPeriodicSyncs(android.accounts.Account account, java.lang.String authority)protected java.util.List<android.content.UriPermission>getPersistedUriPermissions()static android.content.ContentProvidergetProvider(android.net.Uri uri)java.util.List<ShadowContentResolver.Statement>getStatements()Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)static ShadowContentResolver.StatusgetStatus(android.accounts.Account account, java.lang.String authority)static ShadowContentResolver.StatusgetStatus(android.accounts.Account account, java.lang.String authority, boolean create)Retrieve information on the status of the given account.protected static android.content.SyncAdapterType[]getSyncAdapterTypes()protected static booleangetSyncAutomatically(android.accounts.Account account, java.lang.String authority)protected java.lang.StringgetType(android.net.Uri uri)java.util.List<ShadowContentResolver.UpdateStatement>getUpdateStatements()Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)protected android.net.Uriinsert(android.net.Uri url, android.content.ContentValues values)If aContentProvideris registered for the givenUri, itsContentProvider.insert(Uri, ContentValues)method will be invoked.protected static booleanisSyncActive(android.accounts.Account account, java.lang.String authority)protected voidnotifyChange(android.net.Uri uri, android.database.ContentObserver observer)protected voidnotifyChange(android.net.Uri uri, android.database.ContentObserver observer, boolean syncToNetwork)protected java.io.InputStreamopenInputStream(android.net.Uri uri)protected java.io.OutputStreamopenOutputStream(android.net.Uri uri)protected android.database.Cursorquery(android.net.Uri uri, java.lang.String[] projection, android.os.Bundle queryArgs, android.os.CancellationSignal cancellationSignal)protected android.database.Cursorquery(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)protected android.database.Cursorquery(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder, android.os.CancellationSignal cancellationSignal)protected voidregisterContentObserver(android.net.Uri uri, boolean notifyForDescendents, android.database.ContentObserver observer)protected voidregisterContentObserver(android.net.Uri uri, boolean notifyForDescendents, android.database.ContentObserver observer, int userHandle)voidregisterInputStream(android.net.Uri uri, java.io.InputStream inputStream)voidregisterInputStreamSupplier(android.net.Uri uri, java.util.function.Supplier<java.io.InputStream> supplier)voidregisterOutputStream(android.net.Uri uri, java.io.OutputStream outputStream)voidregisterOutputStreamSupplier(android.net.Uri uri, java.util.function.Supplier<java.io.OutputStream> supplier)static voidregisterProviderInternal(java.lang.String authority, android.content.ContentProvider provider)Internal-only method, do not use!protected voidreleasePersistableUriPermission(android.net.Uri uri, int modeFlags)protected static voidremovePeriodicSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras)protected static voidrequestSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras)static voidreset()voidsetContentProviderResult(android.content.ContentProviderResult[] contentProviderResults)Deprecated.voidsetCursor(android.net.Uri uri, BaseCursor cursorForUri)Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)voidsetCursor(BaseCursor cursor)Deprecated.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)protected static voidsetIsSyncable(android.accounts.Account account, java.lang.String authority, int syncable)protected static voidsetMasterSyncAutomatically(boolean sync)voidsetNextDatabaseIdForInserts(int nextId)Deprecated.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)voidsetRegisterContentProviderException(android.net.Uri uri, java.lang.RuntimeException exception)MakesregisterContentObserver(android.net.Uri, boolean, android.database.ContentObserver)throw the specified exception for the specified URI.static voidsetSyncAdapterTypes(android.content.SyncAdapterType[] syncAdapterTypes)Sets the SyncAdapterType array which will be returned bygetSyncAdapterTypes().protected static voidsetSyncAutomatically(android.accounts.Account account, java.lang.String authority, boolean sync)protected voidtakePersistableUriPermission(android.net.Uri uri, int modeFlags)protected voidunregisterContentObserver(android.database.ContentObserver observer)protected intupdate(android.net.Uri uri, android.content.ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)If aContentProvideris registered for the givenUri, itsContentProvider.update(Uri, ContentValues, String, String[])method will be invoked.protected static voidvalidateSyncExtrasBundle(android.os.Bundle extras)
-
-
-
Method Detail
-
reset
@Resetter public static void reset()
-
registerInputStream
public void registerInputStream(android.net.Uri uri, java.io.InputStream inputStream)
-
registerInputStreamSupplier
public void registerInputStreamSupplier(android.net.Uri uri, java.util.function.Supplier<java.io.InputStream> supplier)
-
registerOutputStream
public void registerOutputStream(android.net.Uri uri, java.io.OutputStream outputStream)
-
registerOutputStreamSupplier
public void registerOutputStreamSupplier(android.net.Uri uri, java.util.function.Supplier<java.io.OutputStream> supplier)
-
openInputStream
@Implementation protected final java.io.InputStream openInputStream(android.net.Uri uri)
-
openOutputStream
@Implementation protected final java.io.OutputStream openOutputStream(android.net.Uri uri)
-
insert
@Implementation protected final android.net.Uri insert(android.net.Uri url, android.content.ContentValues values)If aContentProvideris registered for the givenUri, itsContentProvider.insert(Uri, ContentValues)method will be invoked. Tests can verify that this method was called usinggetStatements()orgetInsertStatements(). If no appropriateContentProvideris found, no action will be taken and aUriincluding the incremented value set withsetNextDatabaseIdForInserts(int)will returned.
-
update
@Implementation protected int update(android.net.Uri uri, android.content.ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)If aContentProvideris 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
ContentProvideris found, no action will be taken and 1 will be returned.
-
query
@Implementation(minSdk=26) protected final android.database.Cursor query(android.net.Uri uri, java.lang.String[] projection, android.os.Bundle queryArgs, android.os.CancellationSignal cancellationSignal)
-
query
@Implementation protected final android.database.Cursor query(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)
-
query
@Implementation protected android.database.Cursor query(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder, android.os.CancellationSignal cancellationSignal)
-
getType
@Implementation protected java.lang.String getType(android.net.Uri uri)
-
call
@Implementation protected android.os.Bundle call(android.net.Uri uri, java.lang.String method, java.lang.String arg, android.os.Bundle extras)
-
acquireContentProviderClient
@Implementation protected final android.content.ContentProviderClient acquireContentProviderClient(java.lang.String name)
-
acquireContentProviderClient
@Implementation protected final android.content.ContentProviderClient acquireContentProviderClient(android.net.Uri uri)
-
acquireUnstableContentProviderClient
@Implementation protected final android.content.ContentProviderClient acquireUnstableContentProviderClient(java.lang.String name)
-
acquireUnstableContentProviderClient
@Implementation protected final android.content.ContentProviderClient acquireUnstableContentProviderClient(android.net.Uri uri)
-
acquireProvider
@Implementation protected final android.content.IContentProvider acquireProvider(java.lang.String name)
-
acquireProvider
@Implementation protected final android.content.IContentProvider acquireProvider(android.net.Uri uri)
-
acquireUnstableProvider
@Implementation protected final android.content.IContentProvider acquireUnstableProvider(java.lang.String name)
-
acquireUnstableProvider
@Implementation protected final android.content.IContentProvider acquireUnstableProvider(android.net.Uri uri)
-
delete
@Implementation protected final int delete(android.net.Uri url, java.lang.String where, java.lang.String[] selectionArgs)If aContentProvideris 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 appropriateContentProvideris found, no action will be taken and1will be returned.
-
bulkInsert
@Implementation protected final int bulkInsert(android.net.Uri url, android.content.ContentValues[] values)If aContentProvideris registered for the givenUri, itsContentProvider.bulkInsert(Uri, ContentValues[])method will be invoked. Tests can verify that this method was called usinggetStatements()orgetInsertStatements(). If no appropriateContentProvideris found, no action will be taken and the number of rows invalueswill be returned.
-
notifyChange
@Implementation protected void notifyChange(android.net.Uri uri, android.database.ContentObserver observer, boolean syncToNetwork)
-
notifyChange
@Implementation protected void notifyChange(android.net.Uri uri, android.database.ContentObserver observer)
-
applyBatch
@Implementation protected android.content.ContentProviderResult[] applyBatch(java.lang.String authority, java.util.ArrayList<android.content.ContentProviderOperation> operations) throws android.content.OperationApplicationException- Throws:
android.content.OperationApplicationException
-
requestSync
@Implementation protected static void requestSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras)
-
cancelSync
@Implementation protected static void cancelSync(android.accounts.Account account, java.lang.String authority)
-
isSyncActive
@Implementation protected static boolean isSyncActive(android.accounts.Account account, java.lang.String authority)
-
setIsSyncable
@Implementation protected static void setIsSyncable(android.accounts.Account account, java.lang.String authority, int syncable)
-
getIsSyncable
@Implementation protected static int getIsSyncable(android.accounts.Account account, java.lang.String authority)
-
getSyncAutomatically
@Implementation protected static boolean getSyncAutomatically(android.accounts.Account account, java.lang.String authority)
-
setSyncAutomatically
@Implementation protected static void setSyncAutomatically(android.accounts.Account account, java.lang.String authority, boolean sync)
-
addPeriodicSync
@Implementation protected static void addPeriodicSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras, long pollFrequency)
-
removePeriodicSync
@Implementation protected static void removePeriodicSync(android.accounts.Account account, java.lang.String authority, android.os.Bundle extras)
-
getPeriodicSyncs
@Implementation protected static java.util.List<android.content.PeriodicSync> getPeriodicSyncs(android.accounts.Account account, java.lang.String authority)
-
validateSyncExtrasBundle
@Implementation protected static void validateSyncExtrasBundle(android.os.Bundle extras)
-
setMasterSyncAutomatically
@Implementation protected static void setMasterSyncAutomatically(boolean sync)
-
getMasterSyncAutomatically
@Implementation protected static boolean getMasterSyncAutomatically()
-
takePersistableUriPermission
@Implementation(minSdk=19) protected void takePersistableUriPermission(android.net.Uri uri, int modeFlags)
-
releasePersistableUriPermission
@Implementation(minSdk=19) protected void releasePersistableUriPermission(android.net.Uri uri, int modeFlags)
-
getPersistedUriPermissions
@Implementation(minSdk=19) protected java.util.List<android.content.UriPermission> getPersistedUriPermissions()
-
getProvider
public static android.content.ContentProvider getProvider(android.net.Uri uri)
-
registerProviderInternal
public static void registerProviderInternal(java.lang.String authority, android.content.ContentProvider provider)Internal-only method, do not use!Instead, use
ProviderInfo info = new ProviderInfo(); info.authority = authority; Robolectric.buildContentProvider(ContentProvider.class).create(info);
-
getStatus
public static ShadowContentResolver.Status getStatus(android.accounts.Account account, java.lang.String authority)
-
getStatus
public static ShadowContentResolver.Status getStatus(android.accounts.Account account, java.lang.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 public void setCursor(BaseCursor cursor)
Deprecated.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
-
setCursor
@Deprecated public void setCursor(android.net.Uri uri, BaseCursor cursorForUri)Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
-
setNextDatabaseIdForInserts
@Deprecated public void setNextDatabaseIdForInserts(int nextId)
Deprecated.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
-
getStatements
@Deprecated public java.util.List<ShadowContentResolver.Statement> getStatements()
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)Returns the list ofShadowContentResolver.InsertStatements,ShadowContentResolver.UpdateStatements, andShadowContentResolver.DeleteStatements invoked on thisContentResolver.- Returns:
- a list of statements
-
getInsertStatements
@Deprecated public java.util.List<ShadowContentResolver.InsertStatement> getInsertStatements()
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)Returns the list ofShadowContentResolver.InsertStatements for corresponding calls toContentResolver.insert(Uri, ContentValues)orContentResolver.bulkInsert(Uri, ContentValues[]).- Returns:
- a list of insert statements
-
getUpdateStatements
@Deprecated public java.util.List<ShadowContentResolver.UpdateStatement> getUpdateStatements()
Deprecated.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)Returns the list ofShadowContentResolver.UpdateStatements for corresponding calls toContentResolver.update(Uri, ContentValues, String, String[]).- Returns:
- a list of update statements
-
getDeletedUris
@Deprecated public java.util.List<android.net.Uri> getDeletedUris()
Deprecated.
-
getDeleteStatements
@Deprecated public java.util.List<ShadowContentResolver.DeleteStatement> getDeleteStatements()
Deprecated.Returns the list ofShadowContentResolver.DeleteStatements for corresponding calls toContentResolver.delete(Uri, String, String[]).- Returns:
- a list of delete statements
-
getNotifiedUris
@Deprecated public java.util.List<ShadowContentResolver.NotifiedUri> getNotifiedUris()
Deprecated.
-
getContentProviderOperations
@Deprecated public java.util.List<android.content.ContentProviderOperation> getContentProviderOperations(java.lang.String authority)
Deprecated.
-
setContentProviderResult
@Deprecated public void setContentProviderResult(android.content.ContentProviderResult[] contentProviderResults)
Deprecated.
-
setRegisterContentProviderException
public void setRegisterContentProviderException(android.net.Uri uri, java.lang.RuntimeException exception)MakesregisterContentObserver(android.net.Uri, boolean, android.database.ContentObserver)throw the specified exception for the specified URI.
-
clearRegisterContentProviderException
public void clearRegisterContentProviderException(android.net.Uri uri)
Clears an exception previously set withsetRegisterContentProviderException(Uri, RuntimeException).
-
registerContentObserver
@Implementation protected void registerContentObserver(android.net.Uri uri, boolean notifyForDescendents, android.database.ContentObserver observer)
-
registerContentObserver
@Implementation(minSdk=17) protected void registerContentObserver(android.net.Uri uri, boolean notifyForDescendents, android.database.ContentObserver observer, int userHandle)
-
unregisterContentObserver
@Implementation protected void unregisterContentObserver(android.database.ContentObserver observer)
-
getSyncAdapterTypes
@Implementation protected static android.content.SyncAdapterType[] getSyncAdapterTypes()
-
setSyncAdapterTypes
public static void setSyncAdapterTypes(android.content.SyncAdapterType[] syncAdapterTypes)
Sets the SyncAdapterType array which will be returned bygetSyncAdapterTypes().
-
getContentObservers
public java.util.Collection<android.database.ContentObserver> getContentObservers(android.net.Uri uri)
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
-
-