There is a way to save string value after the app is closed and re open?
I thinking something like Sqlite
but i want to know if there is something easier.
Thanks.
use shared preferences. shared preferences is a mechanism for saving key value pair of data like the string you have!
use this youtube playlist to learn how to use shared preferences. http://goo.gl/DAnQqr
An easier way to do this for a small amount of settings is to use Android's Shared Preferences functionality. It is simpler to code than implementing a full SQLite database.
In Android, it is called SharedPreferences
. You can use that to find many Android java examples which you can port across to Xamarin.
In Xamarin.Android C#, that same functionality comes for the interface ISharedPreferences
, which maps to the SharedPreferences java class.
For example, to save your string using C#, you could write something like:
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (mContext);
prefs.Edit ().PutString ("key_for_my_string_value", mString).Commit ();
To retrieve it again, you could write something like:
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (mContext);
mString= prefs.GetString ("key_for_my_string_value");
More info on ISharedPreferences
in my post here: