Store Data and Access from any Pages in xamarin.Form
The State Persistence between app restarts and when suspending/resuming. The values in the Properties dictionary are only stored when the app goes to Start( OnStart), sleep( OnSleep ), resime ( OnResume) method. I have tried with application crashes out with an exception properties it’s not saved.
This can be accessed from anywhere in your Xamarin
Application
Application different Action:
Refer below code for differentSet value:
Key value always should be
Application. Current. Properties[ "Email"] = "jssuthahar@gmail.com";
if (Application.Current.Properties.ContainsKey("Email"))
{
var emailId = Convert.ToString(Application.Current.Properties["Email"]);
}
If you want to reuse the same key value or update value. just assign value like below
Get Value:
While getting the value, check if its available or not and always convert object type into your specific variable type.if (Application.Current.Properties.ContainsKey("Email"))
{
var emailId = Convert.ToString(Application.Current.Properties["Email"]);
}
If you want to reuse the same key value or update value. just assign value like below
Application.Current.Properties["Email"] = "nikhil@msdn.com";
The properties dictionary can only serialize primitive types for storage. Attempting to store other types like List<int> can fail silently
The properties dictionary can only serialize primitive types for storage. Attempting to store other types like List<int> can fail silently
Remove Value:
If you want to remove application key and value, try below code
if (Application.Current.Properties.ContainsKey("Email"))
{
Application.Current.Properties.Remove("Email");
}
{
Application.Current.Properties.Remove("Email");
}
Clear Value:
You can clear all the application property value
Application.Current.Properties.Clear();
If you have question type(?) ask in Comments Box
If you have question type(?) ask in Comments Box
0 Comments