Free Associate Android Developer Exam Braindumps (page: 6)

Page 5 of 33

What is demonstrated by the code below?

// RawDao.kt
@Dao
interface RawDao {
@RawQuery
fun getUserViaQuery(query: SupportSQLiteQuery?): User?
}

// Usage of RawDao
...
val query =
SimpleSQLiteQuery("SELECT * FROM User WHERE id = ? LIMIT 1",
arrayOf<Any>(sortBy))
val user = rawDao.getUserViaQuery(query)
...

  1. A method in a Dao annotated class as a raw query method where you can pass the query as a
    SupportSQLiteQuery.
  2. A method in a Dao annotated class as a query method.
  3. A method in a RoomDatabase class as a query method.

Answer(s): A



What happens when you create a DAO method and annotate it with @Insert?

Example:
@Dao
interface MyDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertUsers(vararg users: User)
}

  1. Room generates an implementation that inserts all parameters into the database in a single transaction.
  2. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
  3. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

Answer(s): A



What do you want from Room when you create a DAO method and annotate it with @Update?

Example:
@Dao
interface MyDao {
@Update
fun updateUsers(vararg users: User)
}

  1. Room generates an implementation that inserts all parameters into the database in a single transaction.
  2. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
  3. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

Answer(s): B



What do you want from Room when you create a DAO method and annotate it with @Delete?

Example:
@Dao
interface MyDao {
@Delete
fun deleteUsers(vararg users: User)
}

  1. Room generates an implementation that inserts all parameters into the database in a single transaction.
  2. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
  3. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

Answer(s): C






Post your Comments and Discuss Google Associate Android Developer exam with other Community members:

Associate Android Developer Discussions & Posts