title: UnsupportedOperationException while calling getSharedPreferences() from unit test
body: <p>I've implemented Content Provider that retrieves data from a service installed on network.
  The content provider takes required parameters from shared preferences (user credentials, app name, etc.)</p>
  
  <pre><code>SharedPreferences settings = getContext().getSharedPreferences(NET_PREFS, 0);
  </code></pre>
  
  <p>I use unit test for this Content provider:</p>
  
  <pre><code>
  public class ResearchProviderTest extends ProviderTestCase2&lt;MyProvider&gt;{
  
      public ResearchProviderTest() {     
          super(MyProvider.class, MyProvider.CONTENT_AUTHORITY);
      }
  
      public void testInsert() {
  
          ContentValues values = new ContentValues();        
          values.put(QueryFields.FIELD_QUERY_TEXT, "query" );
  
          Uri newUri = getMockContentResolver().insert(MyProvider.CONTENT_URI, values);
  
          Cursor readMessagesCursor = getMockContentResolver().query(
                  newUri ,
                          new String[] { FIELD_SR_TITLE }, 
                          null, null, null );
          assertTrue("The cursor should contain some entries", readMessagesCursor.moveToFirst());
      }
  }
  </code></pre>
  
  <p>During execution of the unit test. The exception is thrown:</p>
  
  <pre><code>
  java.lang.UnsupportedOperationException
     at android.test.mock.MockContext.getSharedPreferences(MockContext.java:127)
     at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:146)
     at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:146)
     at com.company.mobile.android.net.RemoteExecutor.retrieveCredentials(RemoteExecutor.java:171)
     at com.company.mobile.android.net.service.Adapter.executeSearch(Adapter.java:33)
     at com.company.mobile.android.provider.MyProvider.insert(MyProvider.java:167)
     at android.content.ContentProvider$Transport.insert(ContentProvider.java:174)
     ...
  </code></pre>
  
  <p>Does anybody know how to pass Shared Preferences to the MockContext? Should I use other approach if I need Context during testing Content Provider?</p>