Android ContentResolver.query List of Ids (IN statement)

fun importImagesByMediaIds(contentResolver: ContentResolver, mediaIds: List<Long>): Cursor? {    val collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI    val projections = arrayOf(        MediaStore.Images.ImageColumns._ID,        MediaStore.Images.ImageColumns.DATA    )    val selection = "${MediaStore.Images.ImageColumns._ID} IN (${TextUtils.join(",", MutableList(mediaIds.size) { "?" })})"    val selectionArgs = mediaIds.map { it.toString() }.toTypedArray()    return contentResolver.query(collection, projections, selection, selectionArgs, "${MediaStore.Images.ImageColumns.DATE_TAKEN} ASC")}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.