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
2
Q
What are the 3 components that are part of Room
A
- Database - DB holder, has access to the relational DB
- Entities - these are the tables in the DB
- DAO classes - the query methods that provide abstract access to the DB and the mapping of SQL queries to methods
3
Q
What do the DAO classes do?
A
- map methods to SQL queries
- get access to the query DB
4
Q
What indicates an entity class
A
@entity at the top of the class
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
6
Q
How do you auto generate a primary key
A
Using autoGenerate = true
7
Q
What are 4 common methods in the DAO classes
A
@Insert
@Delete
@update
@query
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
9
Q
What is the purpose of the repository in the MVVM
A
Allows access to multiple data sources