Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

xamarin forms shared preferences

$
0
0

Following Code is written into the Shared Project.

Imported Packages

using Android.Content;
using Android.Preferences;

For Storing the value into the Shared Preference

ISharedPreferences pref = PreferenceManager.GetSharedPreferences("UserInfo", FileCreationMode.Private);
ISharedPreferencesEditor edit = pref.Edit();
edit.PutString("Username", username.Text.Trim());
edit.PutString("Password", password.Text.Trim());
edit.Apply();    

For Retrieve the value

ISharedPreferences pref = PreferenceManager.GetSharedPreferences("UserInfo", FileCreationMode.Private);
string userName = pref.GetString("Username", String.Empty);
string password = pref.GetString("Password", String.Empty);

We Got following Error

'Android.Preferences.PreferenceManager' does not contain a definition for 'GetSharedPreferences'

How to use the Shared Preference into Xamarin Forms.?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>