I am trying to integrate Imebra
library to load .dcm
files inside the app. The problem is that as per the documentation, I need to pass the absolute path of the file to Imebra
as shown below:
val loadDataSet = CodecFactory.load("myFile.dcm")
For opening the DCM files, I am using the below code:
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "*/*"
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
}
startActivityForResult(intent, RC_OPEN_FILES)
I am able to get the list of URI's for all the selected files using the below code:
if (data != null) {
val clipData = data.clipData
if (clipData != null) {
// Multiple files selected
val clipDataUriList = arrayListOf<Uri>()
for (i in 0 until clipData.itemCount) {
clipDataUriList.add(clipData.getItemAt(i).uri)
}
processDcmFiles(clipDataUriList)
} else {
// Single file selected
data.data?.let { processDcmFiles(arrayListOf(it)) }
}
}
I tried using uri.getPath()
and creating a File
using the URI and then getting the absolute path but none of them seems to work.
I am not sure if this the right approach to get the absolute path of the files in Android 10. Any help will be appreciated.