Registering the View
Just as we have to teach our RoomDatabase
about entities, we have to teach it about database views. For entities, we have an entities
array that we supply to the @Database
annotation. For database views, we have a view
array that fills the same role:
@Database(
entities = [
AutoGenerateEntity::class,
CompositeKeyEntity::class,
UniqueIndexEntity::class,
IgnoredPropertyEntity::class,
NullablePropertyEntity::class,
CustomColumnNameEntity::class,
IndexedEntity::class,
AppEntity::class,
AggregateEntity::class,
TransmogrifyingEntity::class,
EmbeddedLocationEntity::class,
DefaultValueEntity::class,
com.commonsware.room.misc.onetomany.Book::class,
com.commonsware.room.misc.onetomany.Category::class,
com.commonsware.room.misc.manytomany.Book::class,
com.commonsware.room.misc.manytomany.Category::class,
com.commonsware.room.misc.manytomany.BookCategoryJoin::class,
LinkEntity::class,
CommentEntity::class,
NoteEntity::class,
AutoEnumEntity::class
],
views = [
AppView::class
],
version = 1
)
So, here, we tell MiscDatabase
that we have a single @DatabaseView
, named AppView
.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.