I am working with Xamarin.Forms and I am trying to check if the preferences is empty or null after launching the app. Something like this
InitializeComponent();
if (Preferences.ismpty || Preferences == null)
{
MainPage = new GamerTagPage();
}
else
{
MainPage = new HomePage();
}
You can use
var IsExist = Preferences.ContainsKey("YourKey")
to know if YourKey
exists or no, and for the value you can check it with:
string returnedValue = Preferences.Get("YourKey", string.Empty)
if (string.IsNullOrEmpty(returnedValue))
MainPage = new GamerTagPage();
else
MainPage = new HomePage();