I try to get filepath of image and it works:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE){
val image = data!!.data
val projection: Array<out String> = arrayOf(MediaStore.Images.Media.DATA)
val cursor = context!!.contentResolver.query(selectedImage, projection, null, null, null)
var filepath = ""
if(cursor!!.moveToFirst()){
val columnIndex = cursor.getColumnIndex(projection[0])
filepath = cursor.getString(columnIndex)
}
But MediaStore.Images.Media.DATA is deprecated. How should I get filepath in proper way? I need to make File object to upload it on server.