In this lesson, we'll describe the
@Insert annotation. We'll see how it can be used to provide a convenient way to insert entities into a Room database.
We'll show how to define a function on the
DAO which can be used to insert Tasks into the database. We'll use the
@Insert annotation which will allow us to avoid writing any SQL at all.
Summary of Content:
- Restriction around accessing the database from the UI thread
- Defining an insert function in the DAO
- Returning ID of newly inserted entity
- Returning IDs of newly inserted entities when bulk added
- Room's handling of transactions when using @Insert