Package com.google.android.exoplayer2.database

## Class DefaultDatabaseProvider

- java.lang.Object
- - com.google.android.exoplayer2.database.DefaultDatabaseProvider

- All Implemented Interfaces:
    `DatabaseProvider`

      public final class DefaultDatabaseProvider
      extends Object
      implements DatabaseProvider

  A `DatabaseProvider` that provides instances obtained from a `SQLiteOpenHelper`.

- - ### Field Summary

    - ### Fields inherited from interface com.google.android.exoplayer2.database.DatabaseProvider

      `TABLE_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultDatabaseProvider​(SQLiteOpenHelper sqliteOpenHelper)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `SQLiteDatabase` | `getReadableDatabase()` | Creates and/or opens a database.
    `SQLiteDatabase` | `getWritableDatabase()` | Creates and/or opens a database that will be used for reading and writing.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultDatabaseProvider

          public DefaultDatabaseProvider​(SQLiteOpenHelper sqliteOpenHelper)

      Parameters:
        `sqliteOpenHelper` - An `SQLiteOpenHelper` from which to obtain database instances.

  - ### Method Detail

    - #### getWritableDatabase

          public SQLiteDatabase getWritableDatabase()

      Description copied from interface: `DatabaseProvider`
      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.

      Specified by:
        `getWritableDatabase` in interface `DatabaseProvider`
      Returns:
        A read/write database object.

    - #### getReadableDatabase

          public SQLiteDatabase getReadableDatabase()

      Description copied from interface: `DatabaseProvider`
      Creates and/or opens a database. This will be the same object returned by `DatabaseProvider.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 `DatabaseProvider.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.

      Specified by:
        `getReadableDatabase` in interface `DatabaseProvider`
      Returns:
        A database object valid until `DatabaseProvider.getWritableDatabase()` is called.