title: Unit Test + SQLite Database + Android
body: <p>I need to create Unit tests for the SQLite database in Android to check if reading and writing to the database is being done properly.My database is designed such that whatever table name I pass to the constructor,that table is created in the Database and all read/write methods act on that table.I can then delete the table meant for testing.
  I tried doing this but I guess there is something fundamentally wrong in this approach.This is the Stack Trace :</p>
  
  <pre><code>android.database.sqlite.SQLiteException: no such table: testTable: , while compiling: SELECT key, value FROM testTable WHERE key=?
  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
  at android.database.sqlite.SQLiteCompiledSql.&lt;init&gt;(SQLiteCompiledSql.java:64)
  at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:146)
  at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:367)
  at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:130)
  at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:94)
  at android.database.sqlite.SQLiteQuery.&lt;init&gt;(SQLiteQuery.java:46)
  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1539)
  at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1419)
  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1375)
  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1455)
  at com.amazon.aiv.blast.storage.BlastSQLiteOpenHelper.write(BlastSQLiteOpenHelper.java:93)
  at com.amazon.aiv.blast.test.BlastSQLiteOpenHelperTest.testAddEntry(BlastSQLiteOpenHelperTest.java:25)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:525)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1547)
  </code></pre>
  
  <p>Please suggest me how to run the unit test for the SQLite database.Can I access the database of the actual app for the test app too ?
  Thanks!</p>