Raghav
05/16/2023, 7:58 AMMovie(
val genreIds: List<Int?>?
)
To store the above in database
I'm creating a db table like this
CREATE TABLE Movie (
genreIds TEXT AS List<Int>,
);
While instantiating my database I'll need to give a ColumnAdapter to let the SQLDelight know how to store and retrieve genreIds
to and from database. Here is the ColumnAdapter Implementation
val listOfIntsAdapter = object : ColumnAdapter<List<Int>, String> {
override fun decode(databaseValue: String): List<Int> {
return if (databaseValue.isEmpty()) {
emptyList<Int>()
} else {
databaseValue.split(",").map { it.toInt() }
}
}
override fun encode(value: List<Int>) = value.joinToString(separator = ",")
}
But As I'm building the project I'm getting this error
Type mismatch: inferred type is ColumnAdapter<kotlin.collections.List<Int>, String> but ColumnAdapter<java.util.List<Int>, String> was expected
The name of my database is AppDatabase
In the generated AppDatabaseQueries
class in the imports section, Android Studio is not able to resolve this import.
I don't know but this could be the reason for this issue.
Thanks in advance