Delphi FireMonkey stores data inside the application

I need to save some user static data in my Delphi XE5 FireMonkey (Android) mobile app. I have seen the RC_DATA solution on the Internet, but it is specific to Windows. I need a cross-platform solution.

Here is the RC_DATA solution that I discovered: http://delphidabbler.com/articles?article=2

The comment in the code sample reads: // resource type - RT_RCDATA (from the Windows block)

In conclusion, I came to the conclusion that the code inside the Windows device was specific to Windows. I apologize if this is not so.

Since Chris said that it is essentially cross-platform, I will try. Thanks to Chris.

Regarding the request for a component or library, I read and re-read my question, and I just don't see it. I think the “solution” MAY BE POSSIBLE to include a component or library, but it was never in my head. Again, I apologize if I did something wrong.

goodbye

+6
source share
1 answer

Far from what you call the "RC_DATA" Windows-specific solution, this is actually the most straightforward cross-platform way Delphi provides. What you need to do is add files to the project through Project | Resources and Images ...; since other types of resources are Windows-specific, just stick with RCDATA for each one. Then, to load, use TResourceStream , as you could do in a VCL application ( RT_RCDATA declared in System.Types ):

 procedure LoadStringsFromRes(Strings: TStrings; const ResName: string); var Stream: TResourceStream; begin Stream := TResourceStream.Create(HInstance, ResName, RT_RCDATA); try Strings.LoadFromStream(Stream); finally Stream.Free; end; end; 

In addition, if for some reason you want to check whether a given resource exists before loading, the System block implements the Windows API FindResource for platforms other than Windows.

An alternative to embedded resources is to use Project | Deployment for adding files to an application package (OS X and iOS) or APK (Android). Although this can be considered a more "platform-related" way, the corresponding "remote path" is platform-specific ... and, frankly, if a person is so obsessed with being platform-based, he cannot process embedded resources, then they don’t will use FMX in the first place ...


Update: in relation to the article to which the link is now attached, it shows how to write the RES file manually, which a person usually doesn’t do - if you are not using a small IDE resource manager, then the normal way is to create an RC script and compile it using the compiler Borland or Microsoft resources.

+8
source

All Articles