My example how to select images from local storage:
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    private val galleryLauncher =
        this.registerForActivityResult(ActivityResultContracts.GetMultipleContents()) { images ->
            for (image in images) {
                println(image.path)
            }
        }

    private fun openGallery() {
        galleryLauncher.launch("image/*")
    }

    fun onButtonClick(view: View) {
        openGallery();
    }
}