title: Robolectric accessing database throws an error
body: <p>I have a test that creates an activity which attempts to get some data from the database. This fails with SQLiteException</p>
  
  <pre><code>17:40:40.528 [DEBUG] [TestEventLogger]     android.database.sqlite.SQLiteException: Cannot open SQLite connection, base error code: 14
  17:40:40.528 [DEBUG] [TestEventLogger]      at org.robolectric.shadows.ShadowSQLiteConnection.rethrow(ShadowSQLiteConnection.java:53)
  17:40:40.528 [DEBUG] [TestEventLogger]      at org.robolectric.shadows.ShadowSQLiteConnection.access$600(ShadowSQLiteConnection.java:30)
  17:40:40.529 [DEBUG] [TestEventLogger]      at org.robolectric.shadows.ShadowSQLiteConnection$Connections.execute(ShadowSQLiteConnection.java:443)
  17:40:40.529 [DEBUG] [TestEventLogger]      at org.robolectric.shadows.ShadowSQLiteConnection$Connections.open(ShadowSQLiteConnection.java:345)
  17:40:40.529 [DEBUG] [TestEventLogger]      at org.robolectric.shadows.ShadowSQLiteConnection.nativeOpen(ShadowSQLiteConnection.java:58)
  17:40:40.529 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
  17:40:40.529 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
  17:40:40.529 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
  17:40:40.529 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1142)
  17:40:40.530 [DEBUG] [TestEventLogger]      at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:267)
  17:40:40.531 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
  17:40:40.531 [DEBUG] [TestEventLogger]      at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
  </code></pre>
  
  <p>This used to work fine before I moved my database class to a singleton model. Any suggestions how this should be handled with Robolectric? I couldn't find any documentation or samples on this.</p>
  
  <p>EDIT:</p>
  
  <p>Running Robolectric 3.0 RC-2</p>
  
  <p>Robolectric is driving my activity which attempts to do some work with the database. 
  In my app DB class, removing the check for instance == null from below 'fixes' the issue (i.e. there's no issue with Robolectric running the test if MySQLiteOpenHelper is recreated every time) </p>
  
  <pre><code>public static synchronized MyDataManager getInstance(Context context){
      if (sInstance == null) {
          sInstance = new MyDataManager(context.getApplicationContext());
      }
      return sInstance;
  }
  
  private MyDataManager(Context context) {
      dbHelper = new MySQLiteOpenHelper(context);
  }
  </code></pre>
  
  <p>MySQLiteOpenHelper is a simple extension of SQLiteOpenHelper.</p>
  
  <p>The failure is happening on (again, this is inside by db class):</p>
  
  <pre><code>        database = dbHelper.getWritableDatabase();
  </code></pre>
  
  <p>Obviously I don't really want to recreate a connection every time in my App - and I think nobody would want that? Which makes me think there should be a way to do this properly in Robolectric and I'm just missing a trick here?</p>
  
  <p>EDIT:</p>
  
  <p>Also, the test runs successfully in isolation, which makes me think it's something to do with Robolectric moving between the test cases and reusing the database connection?</p>
  
  <p>Both tests don't do ANYTHING specific to database or related to any of the DB classes. First test starts a fragment which will access the database to write some data. Second test is failing on attempt to open the db as above.</p>