android-room

android left join query with room

与世无争的帅哥 提交于 2020-03-22 08:12:34
问题 I am trying to change my sqlite database with room library. I am little confuse with left join query. I have implemented it with sqlite, but don't know how can I achieve same withh room? Here is my table creation: first table: Notification db.execSQL("CREATE TABLE IF NOT EXISTS $TABLE_NAME ($COLUMN_ID INTEGER PRIMARY KEY, $ICON TEXT, $TITLE INTEGER," + " $DATE INTEGER, $TYPE INTEGER,$URL TEXT, $MESSAGE INTEGER, FOREIGN KEY($TITLE) REFERENCES ${TableNotificationsTrans.getTableName(this)}(id),"

android left join query with room

眉间皱痕 提交于 2020-03-22 08:12:29
问题 I am trying to change my sqlite database with room library. I am little confuse with left join query. I have implemented it with sqlite, but don't know how can I achieve same withh room? Here is my table creation: first table: Notification db.execSQL("CREATE TABLE IF NOT EXISTS $TABLE_NAME ($COLUMN_ID INTEGER PRIMARY KEY, $ICON TEXT, $TITLE INTEGER," + " $DATE INTEGER, $TYPE INTEGER,$URL TEXT, $MESSAGE INTEGER, FOREIGN KEY($TITLE) REFERENCES ${TableNotificationsTrans.getTableName(this)}(id),"

How to save enum field in the database room?

心已入冬 提交于 2020-03-22 06:45:09
问题 I must write the value from the enum enumeration to the database. An error occurs during compilation. What am I doing wrong? Cannot figure out how to save this field into database. You can consider adding a type converter for it. @ColumnInfo(name = "state_of_health") @TypeConverters(HealthConverter::class) var health: Health enum class Health(val value: Int){ NONE(-1), VERY_BAD(0), ... } class HealthConverter{ @TypeConverter fun fromHealth(value: Health): Int{ return value.ordinal }

could the POJO used for Gson reused for the class used with Room

若如初见. 提交于 2020-03-18 04:00:07
问题 when using Gson it has POJO created for parsing/serializing the json data result from the remote service. It may have some Gson's annotation public class User { @SerializedName(“_id”) @Expose public String id; @SerializedName(“_name”) @Expose public String name; @SerializedName(“_lastName”) @Expose public String lastName; @SerializedName(“_age”) @Expose public Integer age; } but for the class using with Room, it may have its own annotation: import android.arch.persistence.room.Entity; import

Room - Select query with IN condition?

人走茶凉 提交于 2020-03-17 04:18:32
问题 Is it possible to use SQLite's IN condition with Room? I'm trying to select a list of items from my database where the value of a certain column (in this case a TEXT column) matches any one of a set of filter values. That's pretty easily done in SQL and SQLite, by my knowledge, just by adding an IN condition to your SELECT statement (see here). However, I can't seem to make it work with Room. I keep getting this error: Error:(70, 25) error: no viable alternative at input 'SELECT * FROM Table

Room one-to-many warning

冷暖自知 提交于 2020-03-16 18:10:06
问题 When creating my contact DAO and related classes, I am getting the following error: The query returns some columns [mContactId, mAddress, mPostcode, mCity, mCountry, mAddressType] which are not used by org.linphone.contacts.managementWS.ContactWithAddresses. You can use @ColumnInfo annotation on the fields to specify the mapping. org.linphone.contacts.managementWS.ContactWithAddresses has some fields [mName, mSurname, mFullName, mCompany, mNote, mIsBlocked] which are not returned by the query

Room one-to-many warning

余生颓废 提交于 2020-03-16 18:08:49
问题 When creating my contact DAO and related classes, I am getting the following error: The query returns some columns [mContactId, mAddress, mPostcode, mCity, mCountry, mAddressType] which are not used by org.linphone.contacts.managementWS.ContactWithAddresses. You can use @ColumnInfo annotation on the fields to specify the mapping. org.linphone.contacts.managementWS.ContactWithAddresses has some fields [mName, mSurname, mFullName, mCompany, mNote, mIsBlocked] which are not returned by the query

Room one-to-many warning

霸气de小男生 提交于 2020-03-16 18:08:22
问题 When creating my contact DAO and related classes, I am getting the following error: The query returns some columns [mContactId, mAddress, mPostcode, mCity, mCountry, mAddressType] which are not used by org.linphone.contacts.managementWS.ContactWithAddresses. You can use @ColumnInfo annotation on the fields to specify the mapping. org.linphone.contacts.managementWS.ContactWithAddresses has some fields [mName, mSurname, mFullName, mCompany, mNote, mIsBlocked] which are not returned by the query

How to store data in room database after fetching from server

∥☆過路亽.° 提交于 2020-03-14 04:57:30
问题 I am using Retrofit2 and Rxjava2 in my android app as a networking library and NodeJS and MongoDB as a backend service.I want to fetch data from server and store data in room database in order to if user open app again it fetches data from room and not from server until some new data is added on server. So far I have successfully fetched data from server and showing it in recycler view. What I want to achieve: 1) Store data in room database after fetching from server. 2) Show data from room

How to store data in room database after fetching from server

前提是你 提交于 2020-03-14 04:57:29
问题 I am using Retrofit2 and Rxjava2 in my android app as a networking library and NodeJS and MongoDB as a backend service.I want to fetch data from server and store data in room database in order to if user open app again it fetches data from room and not from server until some new data is added on server. So far I have successfully fetched data from server and showing it in recycler view. What I want to achieve: 1) Store data in room database after fetching from server. 2) Show data from room