79572492

Date: 2025-04-14 06:40:11
Score: 1.5
Natty:
Report link

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)
Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @CommonsWare
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: theasianpianist