Skill Sprint: Saving and Retrieving Settings Using SaveState

by Jan 12, 2016

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


  • 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



Delphi Skill Sprint