Android Room Flashcards

Room will persist data locally, useful for when the device can not access the network

1
Q

What is Android Room

A
  • Component of Jetpack
  • provides a layer of abstraction over the SQLite DB
  • avoids having to write complex code to access the DB
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 3 components that are part of Room

A
  1. Database - DB holder, has access to the relational DB
  2. Entities - these are the tables in the DB
  3. DAO classes - the query methods that provide abstract access to the DB and the mapping of SQL queries to methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do the DAO classes do?

A
  • map methods to SQL queries
  • get access to the query DB
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What indicates an entity class

A

@entity at the top of the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What becomes the name of the table and how can you change it

A

Name of the class

To change add add (tableName=) aftter the name of the entity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you auto generate a primary key

A

Using autoGenerate = true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are 4 common methods in the DAO classes

A

@Insert
@Delete
@update
@query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why do you need to migrate room databases

A

If you make a change to the schema you need to increase the version number. The migration/upgrade is needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the repository in the MVVM

A

Allows access to multiple data sources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly