Class ShadowSQLiteConnection

    • Field Detail

      • useInMemoryDatabase

        protected static AtomicBoolean useInMemoryDatabase
    • Constructor Detail

      • ShadowSQLiteConnection

        public ShadowSQLiteConnection()
    • Method Detail

      • setUseInMemoryDatabase

        public static void setUseInMemoryDatabase​(boolean value)
      • 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()