Here is a modified version of Sunny's EFile extension, which added some methods that are needed (among others things) for testing purposes with Companion & AKP. Because if you try to save in one of the Shared folders (/Documents or /Download) first with Companion it is not possible to do this without deleting the saved text file before testing with the APK and vice versa (at least on Android 11+). So the Delete & FileExists & API level methods are needed.
The Delete method exists with the File component, but incorrectly requests storage permissions on Android 11+. This bug does not exist with this extension. In order not to be dependent on the File component at all, the required storage permissions for Android < 11 (API < 30) can be declared with this extension DeclareReadWrite.aix in the Manifest.
Version 2 (April 8, 2022): de.bodymindpower.MFile.aix (21.6 KB)
Note: The first version seems to have conflicts with other specific extensions. In this case, use version 2 (compiled with Rush).
Try this app. It saves a text file in the Shared folder /Documents. It should work without storage permissions on Android 11+ using the MFile extension.
If you try do use the File component (Checkbox disabled), you will get a permission error ("Error 908: The permission WRITE_EXTERNAL_STORAGE has been denied. Please enable ..."). In order to work with the File component you MUST set DefaultFileScope to Legacy in the Designer.
This is the only way to declare WRITE permission in the Manifest (even on Android 11+, which of course doesn't make any sense at all, but it is required to work with the File component).
Conclusion
As long as the bugs with the File component are not fixed, I recommend using this extension (MFile), at least on Android 11+.
But if you want to stick with the File component, you MUST ALWAYS set DefaultFileScope to Legacy. Otherwise it will not work on Android 11+ or you MUST save in the ASD or PrivateDir (internal storage).
I want populate a listview from Documents folder, then open a selected one.
I can do it using File1.listDirectory but only with Companion, with apk I need your ext allFilePermission
Because these files were created by Companion. The APK is another app, that cannot access files created by another app (Companion). You must delete these files before testing with the APK.
With your extension mfile I can read write text file in shared folders, it would be fine also to get a list of files, a block Call Mfile1.ListDirectory
Confirmed. However, there doesn't seem to be any problems with other extensions. I added the FileTools extension as a test. APK is built without any problems.
I have now compiled MFile with Rush. The compiling error no longer seems to occur (with the ClickZ ext). > de.bodymindpower.MFile.aix (21.6 KB)
@Patel
Thanks for the link. I have now switched to the extension ClickEvent. Works in my app as well.
@Anke
Thank you very much for your efforts.
I test your extension regarding the error.
Which extension should I use? The version in the 1st post or the version created with Rush?
Frank
Additive:
The extension using Rush produces an error when dragging it into the mobile phone in the designer, see: error.txt (5.3 KB)
Your extension from the first post seems to work after the first tests. I keep testing...
After you have imported an extension, disconnect the companion by Connect > Reset connection. The companion should then automatically exit. If it doesn't, exit the companion and connect again.
That is because Frank imported the extension after he connects to the companion. When you scan the QR code to connect, the computer sends all extensions and assets to the companion, but it shouldn't send extensions during the connection.
Hmm...that's interesting. One of my found errors was resolved by restarting the companion because the user upgraded the extension but did not restart it.
I find this in Taifun's webpage:
While starting the companion app, all necessary assets and also the imported extensions of your project will be copied to your device. So in case the no such class error shows up, the extension code to run the extension is not available on your device. Without that code the companion app is not able to execute methods from the extension.
and:
After importing an extension, please restart the companion app.