I've noticed that files with the storage scope type 'app' can be used to share data between screens. Is this property intended? Is using this property acceptable programming practice?
Explain your concern ?
If you have an app with two real screens, and load a File component into each screen, the File component will have access to the ASD for the app, (where files can be stored by default), which is the same for both screens, given it is the same app.
I can use the same file (storage scope app) across multiple screens modifying it in one screen and using the modified version in another screen. This is very useful and I'd like to use it instead of Tiny DB. I wanted to check that this capability was intended and was acceptable programming practice.
Show an example. Is it a media file or a non-media file?
file scope App means accessing the ASD - Application Specific Directory
so yes or course it is intended to be able to modify the same file from different screens
this btw. should also work for file scope "Shared" and currently I do not know why this should not work for any other file scope (except of Asset, because Asset is read only)
Taifun
Thanks Taifun, I'll continue accessing app files from different screens.
Much appreciated, Peter
Thanks Anke,
Tim and Taifun answered my question, but as you and Tim suggest I should include test blocks and more information. This part of the application uses txt and csv files generated by the app and only used within the app, the data is not shared. I've included two of the three screens as screens 2 and 3 are identical and provided an aia for the app scope that I'm using, and another aia for the shared scope to demonstrate Taifun's second point.
Cheers, Peter
ScreenFilesAppScope.aia (6.2 KB)
ScreenFilesSharedScope.aia (4.4 KB)
Screen 1
Screens 2 and 3
This one doesn't work with Companion and the compiled APK on Android 11+ as it doesn't delete the text file when Companion or the APK is closed. Therefore, after testing with Companion, the file cannot be overwritten via the APK and vice versa.
So either you
- do not test with Companion or
- delete the file via Companion before closing Companion or
- the file name must be different with Companion and APK.
Note: If the user uninstalls and reinstalls the app it does not work anymore, because the reinstalled app is then a new app and cannot overwrite the existing test file. The only way to avoid this is to check if the test file already exists and if so, give it a new name or you must use SAF to access it (on Android 11+).
In addition, no storage permissions should be requested for the Shared
folders on Android 11+. I have pointed out this bug countless times. However, when using the EFile
extension, this is possible on Android 11+ without storage permissions (just as it should be!).
See also here:
Hi Anke,
Agreed. I use the app storage scope for processing data between screens and SAF for backups and sharing files with colleagues or external databases.
I included the shared file scope version as a test because Taifun mentioned it as a theoretical possibility, also I wanted to check whether the absence of a way to set scope to Legacy in the additional screens would cause problems.
For the shared file scope example I changed the file name for a second compilation as you suggested some time ago (you will see the number 2 in the file name). I don't use Companion - no fault of Companion it's just not appropriate for my applications.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.