Sign in Go Pro

Storing Data in Android with Room

Inserting Entities with the @Insert Annotation

11/13/2018

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

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
  • @Insert annotation [android.arch.persistence.room.Insert]
  • 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

Links:

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Storing Data in Android with Room