What are Room Annotations

Alan Ramirez
1 min readSep 20, 2020

--

Room annotations are keywords used to tell the Room persistence library how to treat certain things or scenarios, they are marked with the @ symbol and placed right before the object they are attached to.

@Entity
data class Ingredient(
@PrimaryKey
val ingredientName: String
)

For Example here the @Entity annotation is attached to the Ingredient data class and the @PrimaryKey annotation is attached to the ingredientName val.

At a lower level, annotations are a type of code generator that create boilerplate code for you so you do not need to worry about it.

--

--