android-room

Android Room Persistence Library not working inside library project

房东的猫 提交于 2020-01-24 04:46:05
问题 I'm developping an Android library, and want to use the new Android Room persistence library inside it. However, when launching I got this error : Caused by: java.lang.RuntimeException: cannot find implementation for MyLibraryName.Database.QSDatabase. QSDatabase_Impl does not exist at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:90) which means that the annotationProcessor is not generating the extra code during compilation. Btw, everything is working fine when I

Room: pass columns Name as parameter in DAO Method

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-23 17:07:05
问题 I m using Room to query a table from my local Android sqlite database. I've created an abstract class Dao , and wondering if i can pass the name of columns as parameters in method like this : @Query(value = "SELECT :columnName " + " from " + Constant.TABLE_NAME ) public abstract Maybe<List<SomeEntity>> getResults(String columnName); 回答1: No, sorry, that is not supported. Room only supports what SQLite does, and SQLite does not support parameters for column names, table names, etc. 回答2: Can be

There are multiple good constructors and Room will pick the no-arg constructor. How to solve this warning

萝らか妹 提交于 2020-01-23 09:31:54
问题 I try to implement Room Persistent Database library in android kotlin project, but catch this warning at compile time. I don't know how to solve this warring. warning: There are multiple good constructors and Room will pick the no-arg constructor. You can use the @Ignore annotation to eliminate unwanted constructors. Auto Generated Class public final class Gender { ^ Kotlin Data Class import android.arch.persistence.room.Entity import android.arch.persistence.room.PrimaryKey @Entity data

How to query nested Embeded objects using Room Persistance Library in android?

时光怂恿深爱的人放手 提交于 2020-01-22 18:21:43
问题 Consider I have 3 classes User, Address, Location class Address { public String street; public String state; public String city; @ColumnInfo(name = "post_code") public int postCode; @Embedded(prefix = "home_") public Location homeLocation; @Embedded(prefix = "office_") public Location officeLocation; } class Location{ public long lat; public long lng; } @Entity class User { @PrimaryKey public int id; public String firstName; @Embedded(prefix = "addr_") public Address address; } How should i

How to create a table with a two or more foreign keys using Android Room?

懵懂的女人 提交于 2020-01-21 03:14:49
问题 According the entity-relationship model, the relationship between tbl_post and tbl_category could be specified using Room Persistency Library as follows: @Entity(foreignKeys = @ForeignKey( entity = TblPost.class, parentColumns = "id", childColumns = "tbl_post_id") ) class TblPostCategory { @PrimaryKey public String id; @ColumnInfo(name = "user_id") public String postId; } However TblPostCategory depends on two foreign keys: post_id and category_id from TblPost and TbCategory . How the

How to create a table with a two or more foreign keys using Android Room?

你离开我真会死。 提交于 2020-01-21 03:14:05
问题 According the entity-relationship model, the relationship between tbl_post and tbl_category could be specified using Room Persistency Library as follows: @Entity(foreignKeys = @ForeignKey( entity = TblPost.class, parentColumns = "id", childColumns = "tbl_post_id") ) class TblPostCategory { @PrimaryKey public String id; @ColumnInfo(name = "user_id") public String postId; } However TblPostCategory depends on two foreign keys: post_id and category_id from TblPost and TbCategory . How the

Android Room Database: How to handle Arraylist in an Entity?

梦想与她 提交于 2020-01-18 14:12:47
问题 I just implemented Room for offline data saving. But in an Entity class, I am getting the following error: Error:(27, 30) error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. And the class is as following: @Entity(tableName = "firstPageData") public class MainActivityData { @PrimaryKey private String userId; @ColumnInfo(name = "item1_id") private String itemOneId; @ColumnInfo(name = "item2_id") private String itemTwoId; // THIS IS

Android Room Database: How to handle Arraylist in an Entity?

限于喜欢 提交于 2020-01-18 14:00:13
问题 I just implemented Room for offline data saving. But in an Entity class, I am getting the following error: Error:(27, 30) error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. And the class is as following: @Entity(tableName = "firstPageData") public class MainActivityData { @PrimaryKey private String userId; @ColumnInfo(name = "item1_id") private String itemOneId; @ColumnInfo(name = "item2_id") private String itemTwoId; // THIS IS

Android Room Database: How to handle Arraylist in an Entity?

 ̄綄美尐妖づ 提交于 2020-01-18 13:59:27
问题 I just implemented Room for offline data saving. But in an Entity class, I am getting the following error: Error:(27, 30) error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. And the class is as following: @Entity(tableName = "firstPageData") public class MainActivityData { @PrimaryKey private String userId; @ColumnInfo(name = "item1_id") private String itemOneId; @ColumnInfo(name = "item2_id") private String itemTwoId; // THIS IS

How to store what user have searched and its result

懵懂的女人 提交于 2020-01-16 08:59:42
问题 I want to create a database to store what user have searched, I already have this one : @Entity(tableName = "user_searched") data class UserSearched ( @PrimaryKey @NonNull @ColumnInfo(name = "item") val item: String ) And then I want to link to it the response, it could be a single item or a list of : @Entity(tableName = "my_item") data class MyItem( @PrimaryKey @NonNull @ColumnInfo(name = "id") val id: Int, @ColumnInfo(name = "name") val name: String, @ColumnInfo(name = "description") val