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 TypeMethodDescriptionintinsert(Uri uri, ContentValues originalValues) booleanonCreate()query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) voidshutdown()intupdate(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:
onCreatein classContentProvider
-
query
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) - Specified by:
queryin classContentProvider
-
query
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) - Overrides:
queryin classContentProvider
-
getType
- Specified by:
getTypein interfaceContentInterface- Specified by:
getTypein classContentProvider
-
insert
- Specified by:
insertin classContentProvider
-
delete
- Specified by:
deletein classContentProvider
-
update
- Specified by:
updatein classContentProvider
-
openFile
- Overrides:
openFilein classContentProvider- Throws:
FileNotFoundException
-
shutdown
public void shutdown()- Overrides:
shutdownin classContentProvider
-