SupportSQLiteDatabase
interface SupportSQLiteDatabase : Closeable
androidx.sqlite.db.SupportSQLiteDatabase |
A database abstraction which removes the framework dependency and allows swapping underlying sql versions. It mimics the behavior of android.database.sqlite.SQLiteDatabase
Summary
Public methods | |
---|---|
abstract Unit |
Begins a transaction in EXCLUSIVE mode. |
abstract Unit |
Begins a transaction in IMMEDIATE mode. |
abstract Unit |
beginTransactionWithListener(transactionListener: SQLiteTransactionListener!) Begins a transaction in EXCLUSIVE mode. |
abstract Unit |
beginTransactionWithListenerNonExclusive(transactionListener: SQLiteTransactionListener!) Begins a transaction in IMMEDIATE mode. |
abstract SupportSQLiteStatement! |
compileStatement(sql: String!) Compiles the given SQL statement. |
abstract Int |
Convenience method for deleting rows in the database. |
abstract Unit |
This method disables the features enabled by |
abstract Boolean |
This method enables parallel execution of queries from multiple threads on the same database. |
abstract Unit |
End a transaction. |
abstract Unit |
Execute a single SQL statement that does not return any data. |
abstract Unit |
Execute a single SQL statement that does not return any data. |
abstract MutableList<Pair<String!, String!>!>! |
Returns list of full path names of all attached databases including the main database by executing 'pragma database_list' on the database. |
abstract Long |
Returns the maximum size the database may grow to. |
abstract Long |
Returns the current database page size, in bytes. |
abstract String! |
getPath() Gets the path to the database file. |
abstract Int |
Gets the database version. |
abstract Boolean |
Returns true if the current thread has a transaction pending. |
abstract Long |
insert(table: String!, conflictAlgorithm: Int, values: ContentValues!) Convenience method for inserting a row into the database. |
abstract Boolean |
Runs 'pragma integrity_check' on the given database (and all the attached databases) and returns true if the given database (and all its attached databases) pass integrity_check, false otherwise. |
abstract Boolean |
Returns true if the current thread is holding an active connection to the database. |
abstract Boolean |
isOpen() Returns true if the database is currently open. |
abstract Boolean |
Returns true if the database is opened as read only. |
abstract Boolean |
Returns true if write-ahead logging has been enabled for this database. |
abstract Boolean |
needUpgrade(newVersion: Int) Returns true if the new version code is greater than the current database version. |
abstract Cursor! |
Runs the given query on the database. |
abstract Cursor! |
Runs the given query on the database. |
abstract Cursor! |
query(query: SupportSQLiteQuery!) Runs the given query on the database. |
abstract Cursor! |
query(query: SupportSQLiteQuery!, cancellationSignal: CancellationSignal!) Runs the given query on the database. |
abstract Unit |
setForeignKeyConstraintsEnabled(enable: Boolean) Sets whether foreign key constraints are enabled for the database. |
abstract Unit |
Sets the locale for this database. |
abstract Unit |
setMaxSqlCacheSize(cacheSize: Int) Sets the maximum size of the prepared-statement cache for this database. |
abstract Long |
setMaximumSize(numBytes: Long) Sets the maximum size the database will grow to. |
abstract Unit |
setPageSize(numBytes: Long) Sets the database page size. |
abstract Unit |
Marks the current transaction as successful. |
abstract Unit |
setVersion(version: Int) Sets the database version. |
abstract Int |
update(table: String!, conflictAlgorithm: Int, values: ContentValues!, whereClause: String!, whereArgs: Array<Any!>!) Convenience method for updating rows in the database. |
abstract Boolean |
Temporarily end the transaction to let other threads run. |
abstract Boolean |
yieldIfContendedSafely(sleepAfterYieldDelay: Long) Temporarily end the transaction to let other threads run. |
Extension functions | ||
---|---|---|
From androidx.sqlite.db
|
Public methods
beginTransaction
abstract fun beginTransaction(): Unit
Begins a transaction in EXCLUSIVE mode.
Transactions can be nested. When the outer transaction is ended all of the work done in that transaction and all of the nested transactions will be committed or rolled back. The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.
Here is the standard idiom for transactions:
db.beginTransaction(); try { ... db.setTransactionSuccessful(); } finally { db.endTransaction(); }
beginTransactionNonExclusive
abstract fun beginTransactionNonExclusive(): Unit
Begins a transaction in IMMEDIATE mode. Transactions can be nested. When the outer transaction is ended all of the work done in that transaction and all of the nested transactions will be committed or rolled back. The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.
Here is the standard idiom for transactions:
db.beginTransactionNonExclusive(); try { ... db.setTransactionSuccessful(); } finally { db.endTransaction(); }
beginTransactionWithListener
abstract fun beginTransactionWithListener(transactionListener: SQLiteTransactionListener!): Unit
Begins a transaction in EXCLUSIVE mode.
Transactions can be nested. When the outer transaction is ended all of the work done in that transaction and all of the nested transactions will be committed or rolled back. The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.
Here is the standard idiom for transactions:
db.beginTransactionWithListener(listener); try { ... db.setTransactionSuccessful(); } finally { db.endTransaction(); }
Parameters | |
---|---|
transactionListener |
SQLiteTransactionListener!: listener that should be notified when the transaction begins, commits, or is rolled back, either explicitly or by a call to #yieldIfContendedSafely. |
beginTransactionWithListenerNonExclusive
abstract fun beginTransactionWithListenerNonExclusive(transactionListener: SQLiteTransactionListener!): Unit
Begins a transaction in IMMEDIATE mode. Transactions can be nested. When the outer transaction is ended all of the work done in that transaction and all of the nested transactions will be committed or rolled back. The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.
Here is the standard idiom for transactions:
db.beginTransactionWithListenerNonExclusive(listener); try { ... db.setTransactionSuccessful(); } finally { db.endTransaction(); }
Parameters | |
---|---|
transactionListener |
SQLiteTransactionListener!: listener that should be notified when the transaction begins, commits, or is rolled back, either explicitly or by a call to #yieldIfContendedSafely. |
compileStatement
abstract fun compileStatement(sql: String!): SupportSQLiteStatement!