added readme
This commit is contained in:
16
README.md
16
README.md
@@ -1,4 +1,16 @@
|
|||||||
XamAndroidSettings
|
Xamarin Shared Preference Abstraction
|
||||||
==================
|
==================
|
||||||
|
|
||||||
Abstraction around shared settings in Android xamarin
|
Abstraction around shared settings in Android Xamarin
|
||||||
|
|
||||||
|
## How to use:
|
||||||
|
|
||||||
|
New up a settingskey class
|
||||||
|
|
||||||
|
````c#
|
||||||
|
|
||||||
|
var sk = new SharedSettingsAbstraction.Setting.SettingsKey<string>("KeyName", "PreferenceName", "DefaultValuehere");
|
||||||
|
var setting = sk.getSetting(Context con)
|
||||||
|
var setsetting = sk.SetSetting(Context con, "New Value!")
|
||||||
|
|
||||||
|
````
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ namespace SharedSettingsAbstraction.Setting
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Setting, if it cannot find it or cast properly it will return default setting
|
/// Gets the setting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="con">Context</param>
|
/// <param name="con">context</param>
|
||||||
/// <returns>SettingsKey<T></returns>
|
/// <returns></returns>
|
||||||
public SettingsKey<T> getSetting(Context con )
|
public T getSetting(Context con )
|
||||||
{
|
{
|
||||||
var shared = con.GetSharedPreferences(_preferenceName, FileCreationMode.WorldReadable);
|
var shared = con.GetSharedPreferences(_preferenceName, FileCreationMode.WorldReadable);
|
||||||
try
|
try
|
||||||
@@ -55,7 +55,7 @@ namespace SharedSettingsAbstraction.Setting
|
|||||||
value = (T)_defaultValue;
|
value = (T)_defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return value;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the setting with a new setting
|
/// Set the setting with a new setting
|
||||||
|
|||||||
Reference in New Issue
Block a user