class BitmapListConverter {
@TypeConverter
fun toBitmapList(bitmap: Bitmap): ArrayList<Bitmap> {
return arrayListOf(bitmap)
}
@TypeConverter
fun fromBitmapList(array:ArrayList<Bitmap>): Bitmap {
val bmp = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888)
return if (array.isEmpty()) bmp else array.first() //this causing issue
}
}
Hi I need to converter for ArrayListBitmap for room database but my converter is wrong I think. How can resolve it?
blob thinking upside down 2
not kotlin but kotlin colored 3
c
Christiano
12/03/2023, 10:42 PM
According to this article you could save a bitmap by converting it to base64 before saving and converting it back to a bitmap upon reading it.
Besides this, an SO post also shows that SQLite (which Room uses internally) can also use Blob data, so check out this post for more info.