Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
News

Skill Sprint: Saving and Retrieving Settings Using SaveState

Author: Developer Skill Sprints

Introduction to “SaveState”

  • Persist form & app state between sessions
  • On mobile devices, background apps may be terminated for memory
  • Default saves state to transient / temporary storage
  • Also option to save to persistent storage

TFormSaveState

  • FireMonkey TForm and TForm3D
    • SaveState: TFormSaveState property
    • OnSaveState: TNotifyEvent event
  • TFormSaveState.Stream: TMemoryStream
    • Stream to load and save state from
  • TFormSaveState.StoragePath: String
    • Location persisted too (default is temporary path)
  • TFormSaveState.Name: String
    • Customize persistence file name (allows for multiple files)

Platform Behaviors for SaveState 

  • Android
    • Transient is stored in the native activity
    • Transient state lost if app terminated manually
    • Test with “Developer Options” → “Don’t keep activities”
  • iOS, Windows, OS X
    • Still persisted when app manually terminated
  • Windows & OS X
    • Default location is shared temp folder

More information

Samples

Replays

Delphi Skill Sprint




Register for Python GUI Apps Con 2023 today!

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES