val contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URIval projections = arrayOf( MediaStore.Images.Media._ID, MediaStore.Images.ImageColumns.DATA)contentResolver.query(contentUri, projections, null, null, null)?.use { cursor -> if (cursor.moveToFirst()) { val imageUriIndex = imageCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) } do { val imageUri = imageCursor.getString(imageUriIndex) } while (cursor.moveToNext()) // cursor.close()}
NOTE: Refer use