0

I have big trouble to get the directory that contains a users picked file. The file contains the information for the directory. So I have to read it and then work with tbe files in that directory. The question is how I get from the DocumentFile (file) to the DocumentFile (tree)? getParentFile() sounds good, but always gives null. All File() paths doesn't work. No change to get a working Uri suitable for DocumentFile. I tried with FileProvider but the Google example even does not work because super(R.xml.file_paths) in MyFileProvider does not work because super class doesn't have that constructor. Is it possible with SAF or do I have to do it the stupid way and force the user to pick the file and then pick the correct directory? Then I'll stop development.

DocumentFile file = DocumentFile.fromSingleUri(uri); // ok

DocumentFile parent = file.getParentFile(); // alwas null, how I get documents directory?

Oschi
  • 1
  • 1
    If the user has only selected a single file, you cannot access the folder at all. You would need to have the user select the whole folder using `OpenDocumentTree` if you want access to the whole folder. – ianhanniballake Aug 16 '23 at 17:31
  • `Then I'll stop development` Come on! Everybody does without. – blackapps Aug 16 '23 at 18:00

0 Answers0