public final class

DefaultDatabaseProvider

extends java.lang.Object

implements DatabaseProvider

 java.lang.Object

↳androidx.media3.database.DefaultDatabaseProvider

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-database', version: '1.5.0-alpha01'

  • groupId: androidx.media3
  • artifactId: media3-database
  • version: 1.5.0-alpha01

Artifact androidx.media3:media3-database:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

A DatabaseProvider that provides instances obtained from a .

Summary

Constructors
publicDefaultDatabaseProvider(SQLiteOpenHelper sqliteOpenHelper)

Methods
public SQLiteDatabasegetReadableDatabase()

public SQLiteDatabasegetWritableDatabase()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public DefaultDatabaseProvider(SQLiteOpenHelper sqliteOpenHelper)

Parameters:

sqliteOpenHelper: An from which to obtain database instances.

Methods

public SQLiteDatabase getWritableDatabase()

public SQLiteDatabase getReadableDatabase()

Source

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.media3.database;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.media3.common.util.UnstableApi;

/** A {@link DatabaseProvider} that provides instances obtained from a {@link SQLiteOpenHelper}. */
@UnstableApi
public final class DefaultDatabaseProvider implements DatabaseProvider {

  private final SQLiteOpenHelper sqliteOpenHelper;

  /**
   * @param sqliteOpenHelper An {@link SQLiteOpenHelper} from which to obtain database instances.
   */
  public DefaultDatabaseProvider(SQLiteOpenHelper sqliteOpenHelper) {
    this.sqliteOpenHelper = sqliteOpenHelper;
  }

  @Override
  public SQLiteDatabase getWritableDatabase() {
    return sqliteOpenHelper.getWritableDatabase();
  }

  @Override
  public SQLiteDatabase getReadableDatabase() {
    return sqliteOpenHelper.getReadableDatabase();
  }
}