use of androidx.media3.database.DatabaseIOException in project media by androidx.
the class CacheFileMetadataIndex method getAll.
/**
* Returns all file metadata keyed by file name. The returned map is mutable and may be modified
* by the caller.
*
* <p>This method may be slow and shouldn't normally be called on the main thread.
*
* @return The file metadata keyed by file name.
* @throws DatabaseIOException If an error occurs loading the metadata.
*/
@WorkerThread
public Map<String, CacheFileMetadata> getAll() throws DatabaseIOException {
try (Cursor cursor = getCursor()) {
Map<String, CacheFileMetadata> fileMetadata = new HashMap<>(cursor.getCount());
while (cursor.moveToNext()) {
String name = checkNotNull(cursor.getString(COLUMN_INDEX_NAME));
long length = cursor.getLong(COLUMN_INDEX_LENGTH);
long lastTouchTimestamp = cursor.getLong(COLUMN_INDEX_LAST_TOUCH_TIMESTAMP);
fileMetadata.put(name, new CacheFileMetadata(length, lastTouchTimestamp));
}
return fileMetadata;
} catch (SQLException e) {
throw new DatabaseIOException(e);
}
}
use of androidx.media3.database.DatabaseIOException in project media by androidx.
the class CacheFileMetadataIndex method remove.
/**
* Removes metadata.
*
* <p>This method may be slow and shouldn't normally be called on the main thread.
*
* @param name The name of the file whose metadata is to be removed.
* @throws DatabaseIOException If an error occurs removing the metadata.
*/
@WorkerThread
public void remove(String name) throws DatabaseIOException {
Assertions.checkNotNull(tableName);
try {
SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
writableDatabase.delete(tableName, WHERE_NAME_EQUALS, new String[] { name });
} catch (SQLException e) {
throw new DatabaseIOException(e);
}
}
use of androidx.media3.database.DatabaseIOException in project media by androidx.
the class DefaultDownloadIndex method putDownload.
@Override
public void putDownload(Download download) throws DatabaseIOException {
ensureInitialized();
try {
SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
putDownloadInternal(download, writableDatabase);
} catch (SQLiteException e) {
throw new DatabaseIOException(e);
}
}
Aggregations