Okey, so I tried to follow this guide: https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1 which led me to this code: https://gist.github.com/florina-muntenescu/1c78858f286d196d545c038a71a3e864
I tried to make my own example when I got the following two errors:
Error:Type of the parameter must be a class annotated with @Entity or a collection/array of it.
Error:Cannot use unbound generics in Dao classes. If you are trying to create a base DAO, create a normal class, extend it with type params then mark the subclass with @Dao.
I do not know if those two errors are related to each other, but I can't see where they occur and can there for not rule out that they are related.
@Entity
public class Data {
@PrimaryKey
uuid: String
title: String
}
My parent dao
@Dao
abstract class BaseDao<in T> {
@Insert
abstract fun insert(obj: T)
@Insert
abstract fun insert(vararg obj: T)
@Update
abstract fun update(obj: T)
@Delete
abstract fun delete(obj: T)
}
My subclass dao
@Dao
abstract class SubclassDao : BaseDao<Data> {
@Query("SELECT * FROM Data WHERE uuid = :id")
abstract fun getDataById(id: String): LiveData<Data>
@Query("SELECT * FROM BowelMovementEvent")
abstract fun getData(): List<Data>
@Query("SELECT * FROM BowelMovementEvent")
abstract fun getEventById(id: String): LiveData<Data>
}