John Kouraklis 94 Posted October 27, 2018 Hi, can anyone help me with this? Where am I supposed to store my images on Android? I use the deployment manager to store them in "res\drawable-xxx" but my app does not find it. How do I access the folder from the binary file? I mean, would that be "res\drawable-xxx" or "..\res\drawable-xxx"? Thanks Share this post Link to post
KodeZwerg 54 Posted October 27, 2018 (edited) Maby this way work for you? (uses System.IOUtils) AppPath := TPath.GetHomePath; FileName := TPath.Combine(AppPath, 'Filename.ext'); Edited October 27, 2018 by KodeZwerg 1 Share this post Link to post
DeddyH 0 Posted October 31, 2018 Does this help? Deploying and accessing local files on iOS and Android Share this post Link to post
Dave Nottage 557 Posted November 9, 2018 Is there an issue with using GetDocumentsPath (which in the deployment manager for Android translates to assets/internal), or subfolders thereof? Alternatively, use KodeZwerg's solution. GetHomePath in deployment manager translates to ., i.e. the root Share this post Link to post
Yaron 53 Posted November 12, 2018 Alternatively, you can store your images as resources (project / resources and images) and then use this function to load the images from the resource: procedure LoadImageFromResource(ResourceName : String; TargetBitmap : TBitmap); var rStream : TResourceStream; begin If TargetBitmap <> nil then Begin Try rStream := TResourceStream.Create(hInstance,ResourceName,RT_RCDATA); Except rStream := nil End; if rStream <> nil then Begin Try TargetBitmap.LoadFromStream(rStream); Finally rStream.Free; End; End; End; end; That way you don't care about paths. Share this post Link to post
John Kouraklis 94 Posted November 12, 2018 I know all these approaches (the link, the resources and using getDocumentPath) @Dave Nottage: But this is not the recommended way by Android. I am concerned if those approaches are safe. @Yaron: Is this appropriate way for apps with big number of images? Share this post Link to post
Yaron 53 Posted November 12, 2018 @John Kouraklis I guess it really depends on how the images are used. I use the resource approach where the images are elements in my UI (buttons, sprites, etc). Unlike windows which places all the resources in the executable, if you look into the installation folder on Android, you'll see that all the resource files are in their own folder as actual files, so the resource function is just re-routing to these files. I also use a caching mechanism in my apps where the images are scaled in high quality to the UI resolution and then saved uncompressed to speed up future loads. 1 Share this post Link to post
John Kouraklis 94 Posted November 12, 2018 9 minutes ago, Yaron said: Unlike windows which places all the resources in the executable, if you look into the installation folder on Android, you'll see that all the resource files are in their own folder as actual files, so the resource function is just re-routing to these files. @Yaron That was my concern TBH---a huge file like in Win 10 minutes ago, Yaron said: I also use a caching mechanism in my apps where the images are scaled in high quality to the UI resolution and then saved uncompressed to speed up future loads. I recall a similar discussion somewhere else. 🙂 You mean the original file in the resources is in high-res and then you scale it down to meet the screen resolution, right? and then you store this in a cache directory Share this post Link to post
Yaron 53 Posted November 12, 2018 I use this code for the paths, it works for both Windows and Android UserDataPath := System.IOUtils.TPath.GetHomePath+System.IOUtils.TPath.DirectorySeparatorChar+clientName+System.IOUtils.TPath.DirectorySeparatorChar; cacheFolder := 'cache'+System.IOUtils.TPath.DirectorySeparatorChar; With regards to the UI, yes, I use high resolution source images so the same app will work on any resolution display and maintain a sharp & crisp image. Delphi does a real bad job at high quality image downscaling, but after a year of banging my head against the wall with multiple down-votes and even after offering a bounty on stackoverflow, I finally found a method that will scale the image in high quality using hardware on Android which I posted here: https://stackoverflow.com/questions/52989024/low-quality-delphi-user-interface-design-under-android-when-using-timage If you want to see how bad Delphi's GPU canvas is by default, look at this post:https://stackoverflow.com/questions/51157715/low-quality-downscale-interpolation-when-using-a-gpu-canvas-and-tcanvas-drawbitm Share this post Link to post
Rollo62 536 Posted November 13, 2018 You could consider to use System.IOUtils.TPath.Combine(path1, path2); to get rid of the TPath.DirectorySeparatorChar Share this post Link to post
John Kouraklis 94 Posted November 14, 2018 On 11/13/2018 at 8:43 AM, Rollo62 said: You could consider to use System.IOUtils.TPath.Combine(path1, path2); Yes--that's the recommended way. I can't remember where I read it but Combine takes care any leading slashes based on the OS Share this post Link to post
pcplayer99 11 Posted December 13, 2018 Target: Android, in Deployment windows, if you add your file to remote path: .\assets\internal\, in delphi, you can access it at TPath.GetDocumentsPath. if you have a big number of picture, I suggest you should store it in a SQLite database. When you release you APP, release one file is better than many many files. Share this post Link to post