public abstract static class StorIOSQLite.LowLevel
extends java.lang.Object
StorIOSQLite, we made it separate
to make StorIOSQLite API clean and easy to understand.| Constructor and Description |
|---|
LowLevel() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
beginTransaction()
Begins a transaction in EXCLUSIVE mode.
|
abstract int |
delete(DeleteQuery deleteQuery)
Deletes one or multiple rows in the database.
|
abstract void |
endTransaction()
Ends a transaction.
|
abstract void |
executeSQL(RawQuery rawQuery)
Executes a single SQL statement that
is NOT a SELECT/INSERT/UPDATE/DELETE on the database.
|
abstract long |
insert(InsertQuery insertQuery,
android.content.ContentValues contentValues)
Inserts a row into the database.
|
abstract long |
insertWithOnConflict(InsertQuery insertQuery,
android.content.ContentValues contentValues,
int conflictAlgorithm)
Inserts a row into the database.
|
abstract void |
notifyAboutChanges(Changes changes)
Notifies subscribers about changes happened in
StorIOSQLite. |
abstract android.database.Cursor |
query(Query query)
Executes query on the database and returns
Cursor
over the result set. |
abstract android.database.Cursor |
rawQuery(RawQuery rawQuery)
Executes raw query on the database
and returns
Cursor over the result set. |
abstract void |
setTransactionSuccessful()
Marks the current transaction as successful.
|
abstract android.database.sqlite.SQLiteOpenHelper |
sqliteOpenHelper()
Returns
SQLiteOpenHelper for the direct access to underlining database. |
abstract <T> SQLiteTypeMapping<T> |
typeMapping(java.lang.Class<T> type)
Gets
SQLiteTypeMapping for required type. |
abstract int |
update(UpdateQuery updateQuery,
android.content.ContentValues contentValues)
Updates one or multiple rows in the database.
|
@Nullable public abstract <T> SQLiteTypeMapping<T> typeMapping(@NonNull java.lang.Class<T> type)
SQLiteTypeMapping for required type.
Result can be null.T - type.type - type.SQLiteTypeMapping for required type or null.@WorkerThread
public abstract void executeSQL(@NonNull
RawQuery rawQuery)
rawQuery - sql query.@WorkerThread
@NonNull
public abstract android.database.Cursor rawQuery(@NonNull
RawQuery rawQuery)
Cursor over the result set.rawQuery - sql query@WorkerThread
@NonNull
public abstract android.database.Cursor query(@NonNull
Query query)
Cursor
over the result set.query - sql query.@WorkerThread
public abstract long insert(@NonNull
InsertQuery insertQuery,
@NonNull
android.content.ContentValues contentValues)
insertQuery - query.contentValues - map that contains the initial column values for the row.
The keys should be the column names and the values the column values.@WorkerThread
public abstract long insertWithOnConflict(@NonNull
InsertQuery insertQuery,
@NonNull
android.content.ContentValues contentValues,
int conflictAlgorithm)
insertQuery - query.contentValues - map that contains the initial column values for the row.
The keys should be the column names and the values the column values.conflictAlgorithm - for insert conflict resolver.SQLiteDatabase.CONFLICT_IGNORE
OR -1 if any error.SQLiteDatabase.insertWithOnConflict(String, String, ContentValues, int),
SQLiteDatabase.CONFLICT_REPLACE,
SQLiteDatabase.CONFLICT_ABORT,
SQLiteDatabase.CONFLICT_FAIL,
SQLiteDatabase.CONFLICT_ROLLBACK,
SQLiteDatabase.CONFLICT_IGNORE@WorkerThread
public abstract int update(@NonNull
UpdateQuery updateQuery,
@NonNull
android.content.ContentValues contentValues)
updateQuery - query.contentValues - a map from column names to new column values.
null is a valid value that will be translated to NULL.@WorkerThread
public abstract int delete(@NonNull
DeleteQuery deleteQuery)
deleteQuery - query.public abstract void notifyAboutChanges(@NonNull
Changes changes)
StorIOSQLite.
Operations can be executed in transaction or one operation can affect multiple tables,
so to reduce number of notifications you can call this method once and
provide aggregated Changes object.changes - changes happened in StorIOSQLite.public abstract void beginTransaction()
Thread will be blocked on call to this method if another thread already in transaction, as soon as first thread will end its transaction this thread will be unblocked.
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();
}
public abstract void setTransactionSuccessful()
java.lang.IllegalStateException - if the transaction is already marked as successful.public abstract void endTransaction()
beginTransaction() for notes about
how to use this and when transactions are committed and rolled back.@NonNull public abstract android.database.sqlite.SQLiteOpenHelper sqliteOpenHelper()
SQLiteOpenHelper for the direct access to underlining database.
It can be used in cases when StorIOSQLite APIs are not enough.
Notice: Database changes through the direct access
to the SQLiteOpenHelper will not trigger notifications.
If it possible you should use StorIOSQLite methods instead
or call notifyAboutChanges(Changes) manually.
SQLiteOpenHelper.