In my original post, I omitted the fact that I was saving the URI to RoomDB between creating and trying to read from it. My custom URI TypeConverter for RoomDB was calling uri.path
to convert it to a string, but the path
attribute cuts off the URI scheme (thanks to @CommonsWare for pointing this out in the comments). After changing my TypeConverter to use uri.toString()
, when I retrieve the value from RoomDB I get the complete URI including the content://
prefix indicating the scheme. From there, it's simple to create a bitmap from the retrieved uri using ImageDecoder
and ContentResolver
:
val bitmapSource = ImageDecoder.createSource(contentResolver, uriFromDb)
val bitmap = ImageDecoder.decodeBitmap(bitmapSource)