Using Delphi 10.3.2 Enterprise I ha,ve had little difficulty deploying a FMX app to Android 9 after success on a Windows tablet.
However, I'd like to know how to find the files of the running app, partly because I'd like to sideload some files (not using Google Play during development) and I cannot even see them. I can interrogate GetHomePath and GetDocumentsPath and I see in Deployment manager their Remote Path values. I'm assuming Delphi handles the slash/backslash issues and that's why the app runs at all. I don't even see the "data" folder that is referenced in a lot of on-line guidance.
Using Window's File Explorer, the data folder is still inviisble.
Or am I missing the boat completely and things like FileExists don't actually work in Android?
In any case, I'd still like to be able to browse to the app's files.
All folders in Android which are not 'Shared' type folders can only be seen/accessed from the App itself.
During installation you can only access certain folders to install files in. Ifyou want these files somewhere else, you then must then Move them to the required folder during App startup. That is a pain.
I do stuff like this on startup, to get my sound files into a directory of which I have no access during installation:
if not FileExists(TPath.Combine(TPath.GetRingtonesPath,'SARLog2.wav')) then
on E:Exception do DoLog('Init: Copying SARLog2.wav: '+E.Message,d_error);
I have also written this handy procedure, which will show the files in a directory in 'Linux' format, so you can also see the attributes (which Android will *change* when you copy files into other directories)
procedure ShowDirectory(APath: string);
i, AMax: integer;
AStringDynArray := TDirectory.GetFiles(APath);
AMax := High(AStringDynArray);
DoLog('ShowDirectory: '+APath+'; Count='+IntToStr(AMax));
for i := 0 to AMax do
on E:Exception do DoLog('ShowDirectory: '+E.Message,d_error);
Change the 'DoLog' to whatever log system you use.
Thanks a lot for the interesting code. I'll get back to this app in the next couple of days and see if I can apply this to my particular issues.
Now I understand about folders and files not being visible to just any user so that integrity is maintained. I will try to see if I can use your code to side-step the limitations this brings, by maybe building a side-load feature in the app itself instead of trying to do it at a File Explorer level. This still leaves me wondering two things:1) When people speak of side-loading things on Android, does this refer only to loading entire apps and corresponding sets of files together, as opposed to side-loading something into a different app's folders? What about somebody who just wants to place some media file that more than one app might access?2) Next, though you demonstrate the use of FileExists, I have not even been able to use FileExists to detect the presence of a file in the same folder as the executable, such as finding the SQLite database. I suppose that since, presumably, the folders cannot be tampered with, my app could just assume that the SQLite file is present and simply try to connect to it. I will try to incorporate your approach to use FileExists.
MikeInTaos said:I have not even been able to use FileExists to detect the presence of a file in the same folder as the executable, such as finding the SQLite database.
Then you are likely using it wrong, or you setup the deployment path wrong. Hard to say without seeing your code and setup.
Yes, that's what I've been thinking, though when I looked at the deployment info in the Deployment Manager, it seemed to make sense.... but I'll dig into it some more. I suppose I could put TEdits on the app that allow me to specify a path and file, and a button to apply it to FileExists using TCombine of those params, rather than go through a deployment cycle to try to test each combination until I figure out how these locations are specified on Android.
Have you read the documentation about the Deployment Manager, Loading and Deploying Files for Android, and the Standard RTL Path Functions?
Have a look here:
You need a really wide monitor...
And note that in the Delphi Deployment:
.\assets\internal = TPath.GetDocumentsPath
This is where I load all my files during installation.
I had looked at the Deployment Manager stuff in your link, but that was more than 2 weeks ago so I'll revisit it in light of the examples you've provided plus your new link to Standard RTL Path Functions.If I had known that .\assets\internal = Path.GetDocumentsPath, I had forgotten it, so thanks because that's exactly the kind of think I didn't have at my fingertips.
It turns out that I had the Deployment Manager setting like that at one point, and the corresponding code that turns out to have been correct. What happened was the entry for deploying the SQLite database had gotten removed from the Deployment and once I simply added it back in, the app found the DB and I logged in and could nav through the data.
Now, I just have to start dealing with all the other things about Android that I don't know, such as controlling app rotation and what appears to be forced scaling or cropping of UI elements, but with a working app I can chip away at them. Thanks for helping me get to the first run on the ladder.