Package org.robolectric.fakes
Class FakeMediaProvider
java.lang.Object
android.content.ContentProvider
org.robolectric.fakes.FakeMediaProvider
- All Implemented Interfaces:
ComponentCallbacks
,ComponentCallbacks2
,ContentInterface
A fake implementation of the content provider in MediaStore. The provider is functional and can
be used to populate the android media store in tests.
It currently is a very simplistic implementation compared to the real MediaProvider
Among other limitations, it:
- Only supports media content queries
- Only supports single external storage volume
- Does not support monitoring for file system changes
- Only supports single user
-
Nested Class Summary
Nested classes/interfaces inherited from class android.content.ContentProvider
ContentProvider.CallingIdentity, ContentProvider.PipeDataWriter<T extends Object>
Nested classes/interfaces inherited from interface android.content.ComponentCallbacks2
ComponentCallbacks2.TrimMemoryLevel
-
Field Summary
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
insert
(Uri uri, ContentValues originalValues) boolean
onCreate()
query
(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) void
shutdown()
int
update
(Uri uri, ContentValues values, String selection, String[] selectionArgs) Methods inherited from class android.content.ContentProvider
applyBatch, applyBatch, attachInfo, attachInfoForTesting, bulkInsert, call, call, canonicalize, checkUriPermission, clearCallingIdentity, coerceToLocalContentProvider, createContentUriForUser, delete, dump, enforceReadPermissionInner, enforceWritePermissionInner, getAppOpsManager, getAuthorityWithoutUserId, getCallingAttributionSource, getCallingAttributionTag, getCallingFeatureId, getCallingPackage, getCallingPackageUnchecked, getContext, getIContentProvider, getPathPermissions, getReadPermission, getStreamTypes, getTypeAnonymous, getUriWithoutUserId, getUserHandleFromUri, getUserIdFromAuthority, getUserIdFromAuthority, getUserIdFromUri, getUserIdFromUri, getWritePermission, insert, isAuthorityRedirectedForCloneProfile, isTemporary, matchesOurAuthorities, maybeAddUserId, onCallingPackageChanged, onConfigurationChanged, onLowMemory, onTrimMemory, openAssetFile, openAssetFile, openFile, openFileHelper, openPipeHelper, openTypedAssetFile, openTypedAssetFile, query, refresh, rejectInsert, requireContext, restoreCallingIdentity, setAppOps, setAuthorities, setPathPermissions, setReadPermission, setTransportLoggingEnabled, setWritePermission, uncanonicalize, update, uriHasUserId, validateIncomingUri
-
Constructor Details
-
FakeMediaProvider
public FakeMediaProvider()
-
-
Method Details
-
onCreate
public boolean onCreate()- Specified by:
onCreate
in classContentProvider
-
query
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) - Specified by:
query
in classContentProvider
-
query
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) - Overrides:
query
in classContentProvider
-
getType
- Specified by:
getType
in interfaceContentInterface
- Specified by:
getType
in classContentProvider
-
insert
- Specified by:
insert
in classContentProvider
-
delete
- Specified by:
delete
in classContentProvider
-
update
- Specified by:
update
in classContentProvider
-
openFile
- Overrides:
openFile
in classContentProvider
- Throws:
FileNotFoundException
-
shutdown
public void shutdown()- Overrides:
shutdown
in classContentProvider
-