提问人:YUSUF ORHAN 提问时间:11/16/2023 最后编辑:fraggieYUSUF ORHAN 更新时间:11/21/2023 访问量:45
Android Room & Hilt
Android Room & Hilt
问:
我在 Android Studio 中开发项目时遇到错误。这可能是什么原因?
我在使用Hilt时遇到了这个错误,我不明白原因。
看看随附的代码。
@Dao
interface Product Dao {
@Query("SELECT price FROM products")
suspend fun getTotalAmount(): List<Double>
@Query("SELECT isFavorite FROM products")
suspend fun getFavorite(): List<Boolean>
@Query("SELECT * FROM products")
fun getAllCart(): LiveData<List<ProductModel>>
@Insert
suspend fun insert(productModel: ProductModel)
@Query("DELETE FROM products WHERE id = :uid")
suspend fun delete(uid: Int)
}
class Converters {
private val gson
Gson(){}
@TypeConverter
fun fromProductsItem(item: ProductsItem): String {
return gson.toJson(item)
}
@TypeConverter
fun toProductsItem(itemString: String): ProductsItem {
return gson.fromJson(itemString, ProductsItem::class.java)
}
}
@Dao
interface FavoriteDao {
@Query("SELECT * FROM favorite")|
suspend fun getAllFavorite(): List<Favorite Model>
@Query("SELECT * FROM favorite WHERE uid = :id")
fun getCurrentFavorite(id: Int) : FavoriteModel?
@Insert
suspend fun insertFavorite (favoriteModel: FavoriteModel)
@Query("DELETE FROM favorite WHERE uid = :id")
suspend fun delete(id: Int)
}
答: 暂无答案
评论