Package org.robolectric.shadows
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 forSQLiteConnectionshadow APIs.The actual shadow class for
SQLiteConnectionwill be selected during runtime by the Picker.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowSQLiteConnection.Picker
-
Field Summary
Fields Modifier and Type Field Description protected static AtomicBooleanuseInMemoryDatabase
-
Constructor Summary
Constructors Constructor Description ShadowSQLiteConnection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidreset()static voidsetDefaultJournalMode(String value)Sets the default journal mode for SQLite databases.static voidsetDefaultSyncMode(String value)Sets the default sync mode for SQLite databases.static voidsetDefaultWALSyncMode(String value)Sets the default sync mode for SQLite databases when SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING is used.static voidsetUseInMemoryDatabase(boolean value)static SQLiteMode.ModesqliteMode()
-
-
-
Field Detail
-
useInMemoryDatabase
protected static AtomicBoolean useInMemoryDatabase
-
-
Method Detail
-
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 isPERSISTin SDKs <= 25 andTRUNCATEin SDKs > 25.Similarly to
setDefaultSyncMode(java.lang.String), if your test expects SQLite rollback journal to be synced to disk, usePERSISTorTRUNCATE.
-
reset
@Resetter public static void reset()
-
-