android-room

ROOM Cannot figure out how to save this field into database

半腔热情 提交于 2020-05-16 03:45:06
问题 I need your help. I try to find the solution without deserialize but I didn't find nothing. It would be nice if you can help me... So I have this following JSON file "resources": [{ "id": 441988, "name": "TVA", "parent": { "id": 159 }, }, { "id": 441900, "name": "Marketing", "parent": { "id": 166 }, }] I used ROOM to create a database, it works but I have one problem, its impossible to save "id of Parent object" here is my following code : @Entity(tableName = "resources") class CategoryBean {

ROOM Cannot figure out how to save this field into database

做~自己de王妃 提交于 2020-05-16 03:43:07
问题 I need your help. I try to find the solution without deserialize but I didn't find nothing. It would be nice if you can help me... So I have this following JSON file "resources": [{ "id": 441988, "name": "TVA", "parent": { "id": 159 }, }, { "id": 441900, "name": "Marketing", "parent": { "id": 166 }, }] I used ROOM to create a database, it works but I have one problem, its impossible to save "id of Parent object" here is my following code : @Entity(tableName = "resources") class CategoryBean {

Rxjava 3 + Retrofit2 - multiple inserts to DB problem

风格不统一 提交于 2020-05-15 06:26:38
问题 I am trying to do the following; sync a cloud DB using Retrofit to a local SqLite DB (Room) on a device. The DB could get large, around 100,000 registers or more, so the sync process can take some time. So it send a first Retrofit request to get the number of register, so it can calculate the total number of pages, after that it will send multiple Retrofit Request, to get all the data from API, after each request, it saves the data to Room. Right now, I am having trouble combining two RxJava

Rxjava 3 + Retrofit2 - multiple inserts to DB problem

[亡魂溺海] 提交于 2020-05-15 06:26:25
问题 I am trying to do the following; sync a cloud DB using Retrofit to a local SqLite DB (Room) on a device. The DB could get large, around 100,000 registers or more, so the sync process can take some time. So it send a first Retrofit request to get the number of register, so it can calculate the total number of pages, after that it will send multiple Retrofit Request, to get all the data from API, after each request, it saves the data to Room. Right now, I am having trouble combining two RxJava

Kotlin - Inject Android Room SQL language on multiple line queries

拥有回忆 提交于 2020-05-14 14:39:25
问题 How can I get multi-line queries to be injected? It works on Room with Java classes, but does Kotlin support this as well? E.g. I have 2 queries here, and only the top SQL query (1 line) gets injected. I tried to follow the steps in this guide but could not find the required settings. There is an issue at https://youtrack.jetbrains.com/issue/KT-13636 which suggests this is fixed, but I'm not sure how to implement the fix. 回答1: You can use a raw string which is more readable anyway: @Dao

Android room/TypeConverter issue while retriving list of objects

早过忘川 提交于 2020-05-13 06:37:52
问题 I am implementing a local cache using Room. I have created typeconverter to convert list of objects to json and back. But I am receiving mapping issue while retrieving data from json with error: The columns returned by the query does not have the fields [title,media] in com.example.theApp.data.FlickrImage even though they are annotated as non-null or primitive. Columns returned by the query: [items] Another one like this: error: Cannot figure out how to read this field from a cursor. private

return sum and average using room

筅森魡賤 提交于 2020-05-13 06:19:40
问题 My table is structure is as follows: @Entity(tableName = "userFitnessDailyRecords") public class UserFitnessDailyRecords { @NonNull @PrimaryKey private Date forDay; private int stepCount; } The query I am writing for getting sum and average is as follows: @Dao public interface UserFitnessDailyRecordsDao { @Query("SELECT SUM(stepCount), AVG(stepCount) FROM userFitnessDailyRecords where forDay BETWEEN :startDay AND :endDay ORDER BY forDay ASC") UserFitnessDailyRecords

Android Room - error: Cannot figure out how to save this field into database

让人想犯罪 __ 提交于 2020-05-08 07:57:14
问题 Detailed log error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. private final java.util.Date mTime = null; I have an entity with a field as var mStartTime : Date = Date() // java.util.Date Why cant Room persist Date objects? What can be best converter for Date? 回答1: Date is exactly the example given in https://developer.android.com/training/data-storage/room/referencing-data. For example, if we want to persist instances of Date, we

How to fix the error while saving list of custom data types in room database

江枫思渺然 提交于 2020-04-30 09:31:16
问题 I am trying to save a list of custom data types in room database, actually, I want one of the column should contain list of all transactions show that I don't have to two tables. account.kt @Entity(tableName = "account_table") data class account( @ColumnInfo(name="name") val name:String, @ColumnInfo(name="transaction") val transactions:List<transaction> ){ @PrimaryKey(autoGenerate = true)@ColumnInfo(name="account_id") val accountId:Int=0 } transaction.kt data class transaction( val amount

How to fix the error while saving list of custom data types in room database

懵懂的女人 提交于 2020-04-30 09:27:43
问题 I am trying to save a list of custom data types in room database, actually, I want one of the column should contain list of all transactions show that I don't have to two tables. account.kt @Entity(tableName = "account_table") data class account( @ColumnInfo(name="name") val name:String, @ColumnInfo(name="transaction") val transactions:List<transaction> ){ @PrimaryKey(autoGenerate = true)@ColumnInfo(name="account_id") val accountId:Int=0 } transaction.kt data class transaction( val amount