MockContentResolver
  public
  
  
  
  class
  MockContentResolver
  
  
  
  
    extends ContentResolver
  
  
  
  
  
  
| java.lang.Object | ||
| ↳ | android.content.ContentResolver | |
| ↳ | android.test.mock.MockContentResolver | |
      An extension of ContentResolver that is designed for
      testing.
 
      MockContentResolver overrides Android's normal way of resolving providers by
      authority. To have access to a provider based on its authority, users of
      MockContentResolver first instantiate the provider and
      use MockContentResolver.addProvider(String, ContentProvider). Resolution of an
      authority occurs entirely within MockContentResolver.
 
Users can also set an authority's entry in the map to null, so that a provider is completely mocked out.
Developer Guides
For more information about application testing, read the Testing developer guide.
Summary
| Inherited constants | 
|---|
| Public constructors | |
|---|---|
| 
      MockContentResolver()
      Creates a local map of providers. | |
| 
      MockContentResolver(Context context)
      Creates a local map of providers. | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        void | 
      addProvider(String name, ContentProvider provider)
      Adds access to a provider based on its authority | 
| 
        
        
        
        
        
        void | 
      notifyChange(Collection<Uri> uris, ContentObserver observer, int flags)
      Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. | 
| 
        
        
        
        
        
        void | 
      notifyChange(Uri uri, ContentObserver observer)
      Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. | 
| 
        
        
        
        
        
        void | 
      notifyChange(Uri uri, ContentObserver observer, int flags)
      Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. | 
| 
        
        
        
        
        
        void | 
      notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork)
      
      This method is deprecated.
    callers should consider migrating to
              | 
| Inherited methods | |
|---|---|
Public constructors
MockContentResolver
public MockContentResolver ()
Creates a local map of providers. This map is used instead of the global map when an API call tries to acquire a provider.
MockContentResolver
public MockContentResolver (Context context)
Creates a local map of providers. This map is used instead of the global map when an API call tries to acquire a provider.
| Parameters | |
|---|---|
| context | Context | 
Public methods
addProvider
public void addProvider (String name, ContentProvider provider)
Adds access to a provider based on its authority
| Parameters | |
|---|---|
| name | String: The authority name associated with the provider. | 
| provider | ContentProvider: An instance ofContentProvideror one of its
 subclasses, or null. | 
notifyChange
public void notifyChange (Collection<Uri> uris, ContentObserver observer, int flags)
Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. This effectively hides clients from observers elsewhere in the system.
| Parameters | |
|---|---|
| uris | Collection: This value cannot benull. | 
| observer | ContentObserver: This value may benull. | 
| flags | int: Value is either0or a combination ofContentResolver.NOTIFY_SYNC_TO_NETWORK,ContentResolver.NOTIFY_SKIP_NOTIFY_FOR_DESCENDANTS,ContentResolver.NOTIFY_INSERT,ContentResolver.NOTIFY_UPDATE, andContentResolver.NOTIFY_DELETE | 
notifyChange
public void notifyChange (Uri uri, ContentObserver observer)
Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. This effectively hides clients from observers elsewhere in the system.
| Parameters | |
|---|---|
| uri | Uri: This value cannot benull. | 
| observer | ContentObserver: This value may benull. | 
notifyChange
public void notifyChange (Uri uri, ContentObserver observer, int flags)
Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. This effectively hides clients from observers elsewhere in the system.
| Parameters | |
|---|---|
| uri | Uri: This value cannot benull. | 
| observer | ContentObserver: This value may benull. | 
| flags | int: Value is either0or a combination ofContentResolver.NOTIFY_SYNC_TO_NETWORK,ContentResolver.NOTIFY_SKIP_NOTIFY_FOR_DESCENDANTS,ContentResolver.NOTIFY_INSERT,ContentResolver.NOTIFY_UPDATE, andContentResolver.NOTIFY_DELETE | 
notifyChange
public void notifyChange (Uri uri, ContentObserver observer, boolean syncToNetwork)
      This method is deprecated.
    callers should consider migrating to
             notifyChange(android.net.Uri, android.database.ContentObserver, int), as it
             offers support for many more options than just
             ContentResolver.NOTIFY_SYNC_TO_NETWORK.
  
Overrides the behavior from the parent class to completely ignore any content notifications sent to this object. This effectively hides clients from observers elsewhere in the system.
| Parameters | |
|---|---|
| uri | Uri: This value cannot benull. | 
| observer | ContentObserver: This value may benull. | 
| syncToNetwork | boolean: If true, same asContentResolver.NOTIFY_SYNC_TO_NETWORK. | 
