There are several solutions here involving getting the real file name using getContentResolver(), and pick the original file name from the returned cursor.
None of which will work reliably, particularly with the providers that you cited.
Is there a generic way to obtain an absolute path with the actual file name, change extension and then open it ?
No.
First, there is no absolute path, because the files in question do not have to be on the device. After all, "dropbox, google drive or other" are cloud services, at least for many values of "other". There is no requirement that just because a cloud service downloaded one file to the device, that is has to download all files to the device.
Second, there is no absolute path that you can necessarily use, because an intelligently-written "dropbox, google drive or other" will have the files on the app's portion of internal storage, which your app cannot access.
Third, a Uri
is an opaque handle, just as a URL is. There is no requirement that the Web sites of "dropbox, google drive or other" provide Web URL relative addressing between two arbitrary files held by their services. Similarly, there is no requirement that the on-device file providers provide Uri
relative addressing between two arbitrary files held by their services, or even to use filenames that are recognizable.
The main options that I see for you are:
Have the user pick each file individually.
Have the user combine the files, such as putting them in a ZIP archive.
Have the user pick each file, but in one Storage Access Framework ACTION_OPEN_DOCUMENT
operation, via EXTRA_ALLOW_MULTIPLE
(warning: only practical if your minSdkVersion
is 19 or higher, and you will have to handle the case where the user screws up and does not choose exactly two files).
Have the user organize the files, such as putting them in a single directory/folder, and use the Storage Access Framework's ACTION_OPEN_DOCUMENT_TREE
Intent
(warning: only practical if your minSdkVersion
is 21 or higher).
Switch to using direct Web service APIs for whatever service(s) you wish to integrate with, if they, through their APIs, offer something more amenable to you.