title: Robolectric ContentProvider testing
body: <p>I have noticed that every now and then there is a question about using Robolectric for testing custom ContentProviders. However, there has never been a concrete and unambiguous answer on how to do it properly. I have stumbled upon 2 different approaches:</p>
  
  <ul>
  <li><p>one saying you can simply instantiate an in-memory ContentProvider, which you can use to insert and query data (<a href="https://gist.github.com/anonymous/6139359" rel="noreferrer">https://gist.github.com/anonymous/6139359</a>)</p></li>
  <li><p>the other saying to use the ShadowContentResolver to set mock cursor data (<a href="https://groups.google.com/d/msg/robolectric/r35mMirIkTs/xJJBNXl_RgwJ" rel="noreferrer">https://groups.google.com/d/msg/robolectric/r35mMirIkTs/xJJBNXl_RgwJ</a>)</p></li>
  </ul>
  
  <p>However, I'm getting a java.lang.InstantiationException with both approaches. There have been some SO posts saying that this is due to SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java) not being overriden in Robolectric (<a href="https://stackoverflow.com/questions/16156711/android-robolectric-runtimeexception-instantiationexception-in-querybuilde">Android + Robolectric - RuntimeException / InstantiationException in queryBuilder.query() in ContentProvider</a>). </p>
  
  <p>I guess my question is - are there any preffered workarounds that make testing ContentProviders possible. Or are there any other approaches that are better then those 2 mentioned above.</p>