File: JVE.Configuration.pas Inheritance: TComponent ⬅ TJVEConfiguration
This component allows you to easily store any configuration (hence the name) or other settings, which should be persisted between sessions. This component has no properties or events of its own; instead it provides a property editor allowing you to define multiple persistent properties:
Every value you create belongs to the TJVEConfiguration component, but is also created directly in your code, allowing you type-safe, compile-time verified, access to all the values, as follows: JVEConfiguration1Size1.Value (for the value in the screenshot below).
- Identifier – the identifier to use to access the persistent storage for the variable. Upon a change of this property in the Object Inspector the Name and its source code reference will be reset.
- Default – the default for the value, before another value is stored in the persistent storage. The type of this property depends on the type of the value created.
- Value (runtime only property) – access to this property is actually redirected to the persistent storage; use it to read or write the persistent value.
This component also provides the following class methods (they allow access in runtime, or if you don’t want an overhead of individual value components):
- WriteBool(Ident,Value) – this and other Write functions preserve the value within the persistent storage with the given identifier.
- ReadBool(Ident,Default):Boolean – this and other Read functions retrieve the value from the persistent storage with the given identifier. If no value is preserved therein, return the Default
- ReadInteger(Ident,Default): Integer
- ReadDate(Ident,Default): TDateTime
- ReadDateTime(Ident,Default): TDateTime
- DeleteKey(Ident) – this function deletes a value from the persistent storage. Notice, I have seen this function fail sometimes on the Mac and iOS platforms, it is advisable not to use this function, instead writing the default value back into the storage.
This class uses Windows Registry on MS Windows, JSharedPreferences on Android and NSUserDefaults functionality on other platforms.