by Anonymous » 20 Apr 2025, 06:55
Ich baue eine Android -App mit Kotlin, Raum und Hilt. Ich versuche, in meinem CartDao eine Löschung zu erstellen, um alle Daten aus dem cart -Table zu löschen. Abfragemethoden löschen müssen entweder void oder int zurückgeben (die Anzahl der gelöschten Zeilen).
Code: Select all
@Dao
interface CartDao {
@Query("DELETE FROM cart_table")
fun clearCart() // This line causes the error
}
What I've Tried:
Changing the return type to Int, like this:
kotlin
Copy
Edit
fun clearCart(): Int
Adding suspend to make it a coroutine function:
kotlin
Copy
Edit
@Query("DELETE FROM cart_table")
suspend fun clearCart(): Int
Clean and rebuild the project
What is the correct return type for a DELETE query in Room?
Is there a recommended way to declare a method that deletes all rows in a Room table?
Tech Stack:
Kotlin
Room version: 2.5.2
Hilt
Android Studio Giraffe
Gradle + KAPT
Thanks in advance!
Ich baue eine Android -App mit Kotlin, Raum und Hilt. Ich versuche, in meinem CartDao eine Löschung zu erstellen, um alle Daten aus dem cart -Table zu löschen. Abfragemethoden löschen müssen entweder void oder int zurückgeben (die Anzahl der gelöschten Zeilen).[code]@Dao
interface CartDao {
@Query("DELETE FROM cart_table")
fun clearCart() // This line causes the error
}
What I've Tried:
Changing the return type to Int, like this:
kotlin
Copy
Edit
fun clearCart(): Int
Adding suspend to make it a coroutine function:
kotlin
Copy
Edit
@Query("DELETE FROM cart_table")
suspend fun clearCart(): Int
Clean and rebuild the project
What is the correct return type for a DELETE query in Room?
Is there a recommended way to declare a method that deletes all rows in a Room table?
Tech Stack:
Kotlin
Room version: 2.5.2
Hilt
Android Studio Giraffe
Gradle + KAPT
Thanks in advance!
[/code]