Recently I'm working with a camera app where I need insert all the images I'm doing in the MediaStore. I saw that there is two ways for it, but after read the documentation I don't see any clear difference between both of them.
Using MediaStore
return Images.Media.insertImage(app.contentResolver, metadata.path, metadata.name, "")
Using ContentResolver
val contentValues = ContentValues().apply {
put(Images.Media.DATA, metadata.path)
put(Images.Media.MIME_TYPE, appImg.mimeType)
put(Images.Media.DISPLAY_NAME, metadata.name)
put(Images.Media.DATE_TAKEN, currentTime)
put(Images.Media.DATE_ADDED, currentTime)
put(Images.ImageColumns.SIZE, appImg.sizeInBytes)
put(Images.Media.WIDTH, appImg.width)
put(Images.Media.HEIGHT, appImg.height)
appImg[MediaMetadata.Location]?.let {
put(Images.Media.LATITUDE, it.latitude)
put(Images.Media.LONGITUDE, it.longitude)
}
}
return app.contentResolver.insert(Images.Media.EXTERNAL_CONTENT_URI, contentValues)
Reading some doc I saw that the second one is also creating a thumbnail, but it doesn't explain if it creates it forever, so this will be store in the MediaStore as well and I will be able to query and retrieve the Thumbnails faster.
Anyone have work with both versions and can explain when to use one or the other?