当我试图将Dao更改为新的Flow
API时,我遇到了编译错误,指出
Not sure how to convert a Cursor to this method's return type
public abstract kotlinx.coroutines.flow.Flow<java.util.List<com.ezek.ezign.model.ECampaign>> readCampaigns();
道即为。@Dao
interface CampaignDao {
@Query("SELECT * FROM campaign ORDER BY timeStamp ASC")
fun readCampaigns(): Flow<List<ECampaign>>
@Query("SELECT * FROM campaign WHERE id = :campaignId")
fun readCampaign(campaignId: Int): Flow<ECampaign>
}
并且相关依赖项为
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation "android.arch.persistence.room:runtime:$rootProject.ext.room_version"
kapt "android.arch.persistence.room:compiler:$rootProject.ext.room_version"
//room_version = "2.1.0"
我已经尝试过使用List
和ArrayList
,但没有成功。
提前致谢。
2.4.2
。 - pseudoankit