Package com.inmobi.media.storage.db
Class InMobiDatabaseHelper
-
- All Implemented Interfaces:
public final class InMobiDatabaseHelperThis class is responsible for handling the database and managing its CRUD operations.
-
-
Field Summary
Fields Modifier and Type Field Description private CoroutineDispatcherinternalTransactionDispatcherprivate final SQLiteDatabasewritableDatabase
-
Constructor Summary
Constructors Constructor Description InMobiDatabaseHelper(SQLiteOpenHelper sqLiteOpenHelper, DatabaseConfig databaseConfig)
-
Method Summary
Modifier and Type Method Description final CoroutineDispatchergetInternalTransactionDispatcher()final UnitsetInternalTransactionDispatcher(CoroutineDispatcher internalTransactionDispatcher)final SQLiteDatabasegetWritableDatabase()final Unitinit()Initializes the database helper by obtaining writable and readable database instances. final UnitinsertWithOnConflict(String tableName, ContentValues contentValues, Integer conflictAlgorithm)Inserts a row into the specified table with conflict resolution. final UnitinsertWithOnConflict(String tableName, List<ContentValues> contentValues)Inserts multiple rows into the specified table with conflict resolution. final UnitupdateWithOnConflict(String tableName, ContentValues contentValues, String whereClause, Array<String> whereArgs, Integer conflictAlgorithm)Updates rows in the specified table with conflict resolution. final Unitdelete(String tableName, String whereClause, Array<String> whereArgs)Deletes rows from the specified table. final UnitexecSQL(String query)Executes a raw SQL query. final Integercount(String query)Counts the number of rows that match the specified query. final List<ContentValues>getContentValues(String query)Retrieves a list of ContentValues from the specified query. final Unitwith(SuspendFunction1<InMobiDatabaseHelper, Unit> block)Executes a block of code within a database transaction. -
-
Constructor Detail
-
InMobiDatabaseHelper
InMobiDatabaseHelper(SQLiteOpenHelper sqLiteOpenHelper, DatabaseConfig databaseConfig)
- Parameters:
sqLiteOpenHelper- The SQLiteOpenHelper instance.databaseConfig- The configuration for the database, including context, name, version, table information, journal mode, and transaction executor.
-
-
Method Detail
-
getInternalTransactionDispatcher
final CoroutineDispatcher getInternalTransactionDispatcher()
-
setInternalTransactionDispatcher
final Unit setInternalTransactionDispatcher(CoroutineDispatcher internalTransactionDispatcher)
-
getWritableDatabase
final SQLiteDatabase getWritableDatabase()
-
init
@WorkerThread() final Unit init()
Initializes the database helper by obtaining writable and readable database instances.
-
insertWithOnConflict
final Unit insertWithOnConflict(String tableName, ContentValues contentValues, Integer conflictAlgorithm)
Inserts a row into the specified table with conflict resolution.
- Parameters:
tableName- The name of the table.contentValues- The values to insert.conflictAlgorithm- The conflict resolution algorithm.
-
insertWithOnConflict
final Unit insertWithOnConflict(String tableName, List<ContentValues> contentValues)
Inserts multiple rows into the specified table with conflict resolution.
- Parameters:
tableName- The name of the table.contentValues- The list of values to insert.
-
updateWithOnConflict
final Unit updateWithOnConflict(String tableName, ContentValues contentValues, String whereClause, Array<String> whereArgs, Integer conflictAlgorithm)
Updates rows in the specified table with conflict resolution.
- Parameters:
tableName- The name of the table.contentValues- The new values.whereClause- The optional WHERE clause to apply when updating.whereArgs- The optional arguments for the WHERE clause.conflictAlgorithm- The conflict resolution algorithm.
-
delete
final Unit delete(String tableName, String whereClause, Array<String> whereArgs)
Deletes rows from the specified table.
- Parameters:
tableName- The name of the table.whereClause- The optional WHERE clause to apply when deleting.whereArgs- The optional arguments for the WHERE clause.
-
execSQL
final Unit execSQL(String query)
Executes a raw SQL query.
- Parameters:
query- The SQL query to execute.
-
count
final Integer count(String query)
Counts the number of rows that match the specified query.
- Parameters:
query- The SQL query to count rows.- Returns:
The number of rows that match the query.
-
getContentValues
final List<ContentValues> getContentValues(String query)
Retrieves a list of ContentValues from the specified query.
- Parameters:
query- The SQL query to execute.- Returns:
A list of ContentValues representing the rows that match the query.
-
with
final Unit with(SuspendFunction1<InMobiDatabaseHelper, Unit> block)
Executes a block of code within a database transaction.
- Parameters:
block- The block of code to execute.
-
-
-
-