public abstract @interface DatabaseView
implements Annotation

Marks a class as an SQLite view.

The value of the annotation is a SELECT query used when the view is created.

The class will behave like normal POJO when it is used in a Dao. You can SELECT FROM a DatabaseView similar to an Entity, but you can not INSERT, DELETE or UPDATE into a DatabaseView.

Similar to an Entity, you can use ColumnInfo and Embedded inside to customize the data class.


     "SELECT id, name, release_year FROM Song " +
     "WHERE release_year >= 1990 AND release_year <= 1999")
 public class SongFrom90s {
   long id;
   String name;
   @ColumnInfo(name = "release_year")
   private int releaseYear;

Views have to be registered to a RoomDatabase via Database.views().


Public methods

String value()

The SELECT query.

String viewName()

The view name in the SQLite database.

Inherited methods

Public methods


public String value ()

The SELECT query.

String The SELECT query.


public String viewName ()

The view name in the SQLite database. If not set, it defaults to the class name.

String The SQLite view name.