Reputation: 24592
Looking at a sample Xamarin application I see this code:
protected override void OnSleep()
{
Debug.WriteLine("OnSleep saving ResumeAtTodoId = " + ResumeAtTodoId);
// the app should keep updating this value, to
// keep the "state" in case of a sleep/resume
Properties["ResumeAtTodoId"] = ResumeAtTodoId;
}
In particular Properties["ResumeAtTodoId"]
In my application I have been using a static class like this to hold constants. But would it be better to user Properties
. Is this what is normally used?
namespace Japanese
{
public static class AS
{
public static bool sac; // Score All Cards
public static bool swt; // Show Word Type
Upvotes: 2
Views: 197
Reputation: 858
The Application Properties dictionary is used for storing persistent data. If you want to use data only during one session you should most likely use static class. If you want to persist the data even when the application closes you should use persistent data storage. Read more about the Application Properties here: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/application-class/#Properties_Dictionary
A good alternative to Xamarin Forms Properties dictionary is James Montemagnos Settings plugin which works on Xamarin native versions as well: https://github.com/jamesmontemagno/SettingsPlugin
Upvotes: 1