SAF / Mfile Tests
The following directories are being considered
/Documents, /Download, /Music , /Pictures, /Recordings, /Movies
I've written a test bed see MfileTest.aia. Using SAF I can read a text file from any of these directories, but using the same SAF pathname save to none. Using Mfile I can only save to Documents and Downloads, but using the same MFile pathname cannot read from them.
I’m struggling to understand what seems to be an asymmetry for these read/save actions. Is it Android related? Clearly there must be something wrong with my code. Maybe permissions, but having looked through some previous threads haven’t come up with a solution. I'd just love a decsion tree to determine what routines and permissions are required in particular circumstances - but it seems Google changes the rules every few months and something that worked 12 or 18 months ago now fails
I think the Mfile ReadFrom would work with ApiLevel 33, but can’t see my error. In the case of MFile SaveFile (Anke?) did you decide to limit your extension to just /Documents and /Downloads? I’d really like to be able to write text files to Music as there is a format called abcNotation which is essentially text, although the file extension is .abc It been around for over 20 years. I though Android might have considered /Music to be a Shared folder?
Tests gave the following:
File Read Requests
SAF (Using OpenSingleDocument) can read a text file from all the above directories
The stem pathname being used is content://com.android.externalstorage.doduments.//tree/primary%3A/document/primary%3A Followed by DirName/Filename eg Documents/TestFile.txt
MFile (Using ReadFrom) fails to read from any of the above directories
The stem pathname being used is file:///storage/emulated/0/ followed by DirName/Filename eg Documents/TestFile.txt.
File Save Requests
SAF (Using WriteToFile) fails to save text file to any of the above directories
Get a permissions denied message.. requires MANAGE_DOCUMENTS or grantUriPermission(). Ive no idea how to do either of them.
The SAF stem pathname being used is the same as above for reading files
Mfile (Using SaveFile) can save to Documents, Download
But not to Music, Pictures, Recordings or Movies
The Mfile stem pathname being used is the same as above for reading files
MFileTest.aia (59.0 KB)