@UnstableApi
public final class VersionTable


Utility methods for accessing versions of media library database components. This allows them to be versioned independently to the version of the containing database.

Summary

Constants

static final int

Version of tables used for cache content metadata.

static final int

Version of tables used for cache file metadata.

static final int

Version of tables used from external features.

static final int

Version of tables used for offline functionality.

static final int

Returned by getVersion if the version is unset.

Public methods

static int
getVersion(SQLiteDatabase database, int feature, String instanceUid)

Returns the version of a specified instance of a feature, or VERSION_UNSET if no version is set.

static void
removeVersion(
    SQLiteDatabase writableDatabase,
    int feature,
    String instanceUid
)

Removes the version of a specified instance of a feature.

static void
setVersion(
    SQLiteDatabase writableDatabase,
    int feature,
    String instanceUid,
    int version
)

Sets the version of a specified instance of a specified feature.

Constants

FEATURE_CACHE_CONTENT_METADATA

public static final int FEATURE_CACHE_CONTENT_METADATA = 1

Version of tables used for cache content metadata.

FEATURE_CACHE_FILE_METADATA

public static final int FEATURE_CACHE_FILE_METADATA = 2

Version of tables used for cache file metadata.

FEATURE_EXTERNAL

public static final int FEATURE_EXTERNAL = 1000

Version of tables used from external features.

FEATURE_OFFLINE

public static final int FEATURE_OFFLINE = 0

Version of tables used for offline functionality.

VERSION_UNSET

public static final int VERSION_UNSET = -1

Returned by getVersion if the version is unset.

Public methods

getVersion

public static int getVersion(SQLiteDatabase database, int feature, String instanceUid)

Returns the version of a specified instance of a feature, or VERSION_UNSET if no version is set.

Parameters
SQLiteDatabase database

The database to query.

int feature

The feature.

String instanceUid

The unique identifier of the instance of the feature.

Returns
int

The version, or VERSION_UNSET if no version is set.

Throws
androidx.media3.database.DatabaseIOException

If an error occurs executing the SQL.

removeVersion

public static void removeVersion(
    SQLiteDatabase writableDatabase,
    int feature,
    String instanceUid
)

Removes the version of a specified instance of a feature.

Parameters
SQLiteDatabase writableDatabase

The database to update.

int feature

The feature.

String instanceUid

The unique identifier of the instance of the feature.

Throws
androidx.media3.database.DatabaseIOException

If an error occurs executing the SQL.

setVersion

public static void setVersion(
    SQLiteDatabase writableDatabase,
    int feature,
    String instanceUid,
    int version
)

Sets the version of a specified instance of a specified feature.

Parameters
SQLiteDatabase writableDatabase

The database to update.

int feature

The feature.

String instanceUid

The unique identifier of the instance of the feature.

int version

The version.

Throws
androidx.media3.database.DatabaseIOException

If an error occurs executing the SQL.