DefaultDatabaseProvider


@UnstableApi
class DefaultDatabaseProvider : DatabaseProvider


A DatabaseProvider that provides instances obtained from a SQLiteOpenHelper.

Summary

Public constructors

Public functions

SQLiteDatabase!

Creates and/or opens a database.

SQLiteDatabase!

Creates and/or opens a database that will be used for reading and writing.

Inherited Constants

From androidx.media3.database.DatabaseProvider
const String!
TABLE_PREFIX = "ExoPlayer"

Prefix for tables that can be read and written by media library components.

Public constructors

DefaultDatabaseProvider

DefaultDatabaseProvider(sqliteOpenHelper: SQLiteOpenHelper!)
Parameters
sqliteOpenHelper: SQLiteOpenHelper!

An SQLiteOpenHelper from which to obtain database instances.

Public functions

getReadableDatabase

fun getReadableDatabase(): SQLiteDatabase!

Creates and/or opens a database. This will be the same object returned by getWritableDatabase unless some problem, such as a full disk, requires the database to be opened read-only. In that case, a read-only database object will be returned. If the problem is fixed, a future call to getWritableDatabase may succeed, in which case the read-only database object will be closed and the read/write object will be returned in the future.

Once opened successfully, the database is cached, so you can call this method every time you need to read from the database.

Returns
SQLiteDatabase!

A database object valid until getWritableDatabase is called.

Throws
android.database.sqlite.SQLiteException

If the database cannot be opened.

getWritableDatabase

fun getWritableDatabase(): SQLiteDatabase!

Creates and/or opens a database that will be used for reading and writing.

Once opened successfully, the database is cached, so you can call this method every time you need to write to the database. Errors such as bad permissions or a full disk may cause this method to fail, but future attempts may succeed if the problem is fixed.

Returns
SQLiteDatabase!

A read/write database object.

Throws
android.database.sqlite.SQLiteException

If the database cannot be opened for writing.