If you added to your build.gradle file a room.schemaLocation:
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString
()]
}
}
}
}
Then, you build your app or module.
As a result you got a json file, with such path to it: app/schemas/your_app_package/db_package/DbClass/DB_VERSION.json What are the correct statements about this file? (Choose all that apply.)
Exported schema file example:
{
'formatVersion': 1,
'database': {
'version': 1,
'identityHash': 'd90c93040756d2b94a178d5555555555',
'entities': [
{
'tableName': 'tea_table',
'createSql': 'CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER
PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `type` TEXT, `origin` TEXT,
`steep_times` INTEGER, `Description` TEXT, `ingredients` TEXT, `cafeinLevel` TEXT, `favorite` INTEGER)',
'fields': [
{
'fieldPath': 'mId',
'columnName': 'id',
'affinity': 'INTEGER',
'notNull': true
},
{
'fieldPath': 'mName',
'columnName': 'name',
'affinity': 'TEXT',
'notNull': false
},
{
'fieldPath': 'mType',
'columnName': 'type',
'affinity': 'TEXT',
'notNull': false
},
{
'fieldPath': 'mOrigin',
'columnName': 'origin',
'affinity': 'TEXT',
'notNull': false
},
{
'fieldPath': 'mSteepTimeMs',
'columnName': 'steep_times',
'affinity': 'INTEGER',
'notNull': false
},
{
'fieldPath': 'mDescription',
'columnName': 'Description',
'affinity': 'TEXT',
'notNull': false
},
{
'fieldPath': 'mIngredients',
'columnName': 'ingredients',
'affinity': 'TEXT',
'notNull': false
},
{
'fieldPath': 'mCaffeineLevel',
'columnName': 'cafeinLevel',
'affinity': 'TEXT',
'notNull': false
},
{
'fieldPath': 'mFavorite',
'columnName': 'favorite',
'affinity': 'INTEGER',
'notNull': false
}
],
'primaryKey': {
'columnNames': [
'id'
],
'autoGenerate': true
},
'indices': [],
'foreignKeys': []
}
],
'views': [],
'setupQueries': [
'CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY
KEY,identity_hash TEXT)',
'INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42,
'd90c93040756d2b94a178d5555555555')'
]
}
}
In our TeaViewModel class, that extends ViewModel, we have such prorerty:
val tea: LiveData
An observer in our Activity (type of mViewModel variable in example is TeaViewModel) is set in this way:
mViewModel!!.tea.observe(this, Observer { tea: Tea? -> displayTea(tea) })
What will be a correct displayTea method definition?
About queries in DAO classes. Room verifies the return value of the query such that if the name of the field in the returned object doesn't match the corresponding column names in the query response, Room alerts you in one of the following two ways: (Choose two.)
For example, we have a BufferedReader reader, associated with the json file through
InputStreamReader. To get a file data we can do this:
Viola
8 months agoJenise
9 months agoLeonora
10 months agoFannie
10 months ago