Reputation: 1
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?
Upvotes: 0
Views: 113