Class ShadowSQLiteConnection

java.lang.Object
org.robolectric.shadows.ShadowSQLiteConnection
Direct Known Subclasses:
ShadowLegacySQLiteConnection, ShadowNativeSQLiteConnection

@Implements(className="android.database.sqlite.SQLiteConnection",
            isInAndroidSdk=false,
            shadowPicker=Picker.class)
public class ShadowSQLiteConnection
extends Object
The base shadow class for SQLiteConnection shadow APIs.

The actual shadow class for SQLiteConnection will be selected during runtime by the Picker.

  • Field Details

  • Constructor Details

  • Method Details

    • setUseInMemoryDatabase

      public static void setUseInMemoryDatabase​(boolean value)
    • sqliteMode

      public static SQLiteMode.Mode sqliteMode()
    • setDefaultSyncMode

      public static void setDefaultSyncMode​(String value)
      Sets the default sync mode for SQLite databases. Robolectric uses "OFF" by default in order to improve SQLite performance. The Android default is "FULL" in order to be more resilient to process crashes. However, this is not a requirement for Robolectric processes, where all database files are temporary and get deleted after each test.

      If your test expects SQLite files being synced to disk, such as having multiple processes interact with the database, or deleting SQLite files while connections are open and having this reflected in the open connection, use "FULL" mode.

    • setDefaultWALSyncMode

      public static void setDefaultWALSyncMode​(String value)
      Sets the default sync mode for SQLite databases when SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING is used. Robolectric uses "OFF" by default in order to improve SQLite performance. The Android default is "FULL" for SDKs < 28 and "NORMAL" for SDKs >= 28.

      If your test expects SQLite files being synced to disk, such as having multiple processes interact with the database, or deleting SQLite files while connections are open and having this reflected in the open connection, use "FULL" mode.

    • setDefaultJournalMode

      public static void setDefaultJournalMode​(String value)
      Sets the default journal mode for SQLite databases. Robolectric uses "MEMORY" by default in order to improve SQLite performance. The Android default is PERSIST in SDKs <= 25 and TRUNCATE in SDKs > 25.

      Similarly to setDefaultSyncMode(java.lang.String), if your test expects SQLite rollback journal to be synced to disk, use PERSIST or TRUNCATE.

    • reset

      @Resetter public static void reset()