I am working on an application to read excel file (xlsx) file data. I was using custom file picker to select the file in android 10 and below, But in Andrid 11 it doesnt show the xlsx files.
So i made a change in my code for Android 11.
//to launch file picker
getContent.launch("*/*")
//to read selected file
val getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
readExcelData(uri!!.path!!)
}
the above code "uri!!.path!!" gives exception
/document/primary:Android/OldFileWithNewRecords.xlsxException:
E/ExcelActivity: FileNotFoundException/document/primary:Android/OldFileWithNewRecords.xlsx: open failed: ENOENT (No such file or directory)
Is there any way i can get the exact path of the file selected?
I tried SimpleStorage and this solution but was not able to succeed.