Local Storage Demo 2
This version of the Smart Mobile Studio storage demo saves a string the first time the program is run and loads then outputs the string on subsequent runs. Change SmartCL.Storage in the uses clause to SmartCL.Storage.Local when using Version 3.0 of Smart Mobile Studio.
unit Unit1; interface uses System.Types, System.Lists, SmartCL.System, SmartCL.Scroll, SmartCL.Console, SmartCL.Components, SmartCL.Application, SmartCL.ConsoleApp, SmartCL.Storage; type TApplication = class(TW3CustomConsoleApplication) private FStorage: TW3LocalStorage; protected procedure ApplicationStarting; override; procedure PopulateConsole; override; procedure ApplicationClosing; override; end; implementation procedure TApplication.ApplicationStarting; begin FStorage := TW3LocalStorage.Create; FStorage.Open('Demo2'); inherited; end; procedure TApplication.PopulateConsole; var s: String; begin s := FStorage.getKeyStr('myText', 'error'); if s = 'error' then begin FStorage.setKeyStr('myText', 'Saved string'); Console.WriteLn('Saving string.'); end else begin s := FStorage.getKeyStr('myText', 'error'); Console.WriteLn('String already saved: ' + s); end; end; procedure TApplication.ApplicationClosing; begin FStorage.Close; inherited; end; end.