I am wondering if one can get a java.io.File from a DocumentFile.
Yes mostly you can. If the user chooses a 'file' from primary or secondary storage you can as there is a one to one relationship between the content scheme and the file path of a file or directory.
But if you really need java.io.File you could better use a file picker.
[UPDATE]
content://com.android.externalstorage.documents/tree/primar%3ADCIM%2Fdeeper%2Fevendeeper
content://com.android.externalstorage.documents/tree/primary:DCIM/deeper/evendeeper
if that e.g. corresponds with
/storage/emulated/0/DCIM/deeper/evendeeper.
And
content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fcom.aaaa.org%2Ffiles%2Fafile.txt
content://com.android.externalstorage.documents/tree/primary:Android/com.aaaa.org/files/afile.txt
transforms in
/storage/emulated/0/Android/com.aaa.org/files/afile.txt
Then follows if you know one you know them all: there is a one to one relationship.
The only thing you have to do for conversion is replacing content://com.android.externalstorage.documents/tree/primary:
by /storage/emulated/0/
This reduces the problem to determining /storage/emulated/0/
.
For that you once have to let the user choose the root of the file system path for the choosen content scheme. If it cannot be choosed that it often can be found with a file explorer app on the device. Finally you can let the path beeing typed in.
Precisely the opposite as done in Android SAF (Storage Access FrameWork): Get particular file Uri from TreeUri or in other posts with tag storage-acccess-framework
.