Reputation: 705
I don't know what's wrong with below problem?
Code:
CategoryDAO.kt
@Dao
interface CategoryDAO {
@Query("select * from CategoryDesign")
suspend fun getCategory(): MutableLiveData<List<CategoryDesign>>
}
CategoryDesign.kt
@Entity
data class CategoryDesign (
@PrimaryKey
var categoryDesignID:String,
var designImage:String,
var designTitle:String){
constructor() : this("","","")
override fun toString(): String {
return designTitle
}
}
Press Run App button will show error like below:
error: Not sure how to convert a Cursor to this method's return type (androidx.lifecycle.MutableLiveData<java.util.List<com.squall.searchdesigner.model.CategoryDesign>>).
public abstract java.lang.Object getCategory(@org.jetbrains.annotations.NotNull()
w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC), android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC).
dependencies:
dependencies {
def room_version = "2.2.3"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
}
Upvotes: 0
Views: 308
Reputation: 705
Thank you all. I used below code and rebuild project and invalidate caches seems solve this problem.
@Dao
interface CategoryDAO {
@Query("select * from CategoryDesign")
fun getCategory(): LiveData<MutableList<CategoryDesign>>
}
Upvotes: 0
Reputation: 165
It's seems like you can use only LiveData return type. Maybe Room not allows you to use MutableLiveData?
Upvotes: 0