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 forSQLiteConnection
shadow APIs.The actual shadow class for
SQLiteConnection
will be selected during runtime by the Picker.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowSQLiteConnection.Picker
-
Field Summary
Fields Modifier and Type Field Description protected static AtomicBoolean
useInMemoryDatabase
-
Constructor Summary
Constructors Constructor Description ShadowSQLiteConnection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
reset()
static void
setDefaultJournalMode(String value)
Sets the default journal mode for SQLite databases.static void
setDefaultSyncMode(String value)
Sets the default sync mode for SQLite databases.static void
setDefaultWALSyncMode(String value)
Sets the default sync mode for SQLite databases when SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING is used.static void
setUseInMemoryDatabase(boolean value)
static SQLiteMode.Mode
sqliteMode()
-
-
-
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 isPERSIST
in SDKs <= 25 andTRUNCATE
in SDKs > 25.Similarly to
setDefaultSyncMode(java.lang.String)
, if your test expects SQLite rollback journal to be synced to disk, usePERSIST
orTRUNCATE
.
-
reset
@Resetter public static void reset()
-
-