Room - nikitachebotarev/docs GitHub Wiki

Annotations

  • @Database (Marks a class as a RoomDatabase. The class should be an abstract class and extend RoomDatabase. You can receive an implementation of the class via Room.databaseBuilder or Room.inMemoryDatabaseBuilder.)
  • @Entity (Marks a class as an entity. This class will have a mapping SQLite table in the database. Each entity must have at least 1 field annotated with PrimaryKey. You can also use primaryKeys() attribute to define the primary key. Each entity must either have a no-arg constructor or a constructor whose parameters match fields (based on type and name). Constructor does not have to receive all fields as parameters but if a field is not passed into the constructor, it should either be public or have a public setter. If a matching constructor is available, Room will always use it. If you don't want it to use a constructor, you can annotate it with Ignore. When a class is marked as an Entity, all of its fields are persisted. If you would like to exclude some of its fields, you can mark them with Ignore.)
  • @Dao (The class marked with @Dao should either be an interface or an abstract class. At compile time, Room will generate an implementation of this class when it is referenced by a Database.)
  • @ColumnInfo Allows specific customization about the column associated with this field.
  • @ColumnInfo.Collate
  • @ColumnInfo.SQLiteTypeAffinity The SQLite column type constants that can be used in ColumnInfo.typeAffinity()
  • @DatabaseView Marks a class as an SQLite view.
  • @Delete Marks a method in a Dao annotated class as a delete method.
  • @Embedded Marks a field of an Entity or POJO to allow nested fields (i.e.
  • @ForeignKey Declares a foreign key on another Entity.
  • @ForeignKey.Action Constants definition for values that can be used in ForeignKey.onDelete() and ForeignKey.onUpdate().
  • @Fts3 Marks an Entity annotated class as a FTS3 entity.
  • @Fts4 Marks an Entity annotated class as a FTS4 entity.
  • @Ignore Ignores the marked element from Room's processing logic.
  • @Index Declares an index on an Entity.
  • @Insert Marks a method in a Dao annotated class as an insert method.
  • @Junction Declares a junction to be used for joining a relationship.
  • @OnConflictStrategy Set of conflict handling strategies for various Dao methods.
  • @PrimaryKey Marks a field in an Entity as the primary key.
  • @Query Marks a method in a Dao annotated class as a query method.
  • @RawQuery Marks a method in a Dao annotated class as a raw query method where you can pass the query as a SupportSQLiteQuery.
  • @Relation A convenience annotation which can be used in a POJO to automatically fetch relation entities.
  • @RewriteQueriesToDropUnusedColumns When present, RewriteQueriesToDropUnusedColumns annotation will cause Room to rewrite your Query methods such @that only the columns that are used in the response are queried from the database.
  • @SkipQueryVerification Skips database verification for the annotated element.
  • @Transaction Marks a method in a Dao class as a transaction method.
  • @TypeConverter Marks a method as a type converter.
  • @TypeConverters Specifies additional type converters that Room can use.
  • @Update Marks a method in a Dao annotated class as an update method.