4 <name>Tizen.Applications.Preference</name>
7 <member name="T:Interop">
9 Contains interop declarations of the preference classes.
12 <member name="T:Interop.Preference">
14 Contains interop declarations of the preference device API.
17 <member name="T:Tizen.Applications.Preference">
19 The preference class provides APIs to store and retrieve an application specific data/preference. A preference is saved in the form of a key-value pair.
20 Keys are always text strings and the value can be any one of the four types: integer, double, string, and boolean.
23 <member name="P:Tizen.Applications.Preference.Keys">
25 Retrieves all keys of the application preferences.
32 Preference.Set("Option_enabled", true);
33 Preference.Set("active_user", "Joe");
34 Preference.Set("default_volume", 10);
35 Preference.Set("brightness", "0.6");
36 foreach(string key in Preference.Keys)
38 Console.WriteLine("key {0}", key);
43 <member name="M:Tizen.Applications.Preference.GetEventContext(System.String)">
45 Gets the event context for the given key.
47 <seealso cref="T:Tizen.Applications.Preference.EventContext"/>
48 <param name="key">The preference key.</param>
49 <returns>The event context of respective key.</returns>
50 <exception cref="T:System.Collections.Generic.KeyNotFoundException">Thrown if the key is not found.</exception>
51 <exception cref="T:System.ArgumentException">Thrown if the key is invalid parameter.</exception>
54 private static void Preference_PreferenceChanged(object sender, PreferenceChangedEventArgs e)
56 Console.WriteLine("key {0}", e.Key);
59 Preference.EventContext context = null;
60 Preference.GetEventContext("active_user").TryGetTarget(out context);
63 context.Changed += Preference_PreferenceChanged;
66 Preference.Set("active_user", "Poe");
68 Preference.GetEventContext("active_user").TryGetTarget(out context);
71 context.Changed -= Preference_PreferenceChanged;
76 <!-- Badly formed XML comment ignored for member "M:Tizen.Applications.Preference.Contains(System.String)" -->
77 <!-- Badly formed XML comment ignored for member "M:Tizen.Applications.Preference.Set(System.String,System.Object)" -->
78 <!-- Badly formed XML comment ignored for member "M:Tizen.Applications.Preference.Get``1(System.String)" -->
79 <member name="M:Tizen.Applications.Preference.Remove(System.String)">
81 Removes any preference value with the given key.
83 <param name="key">The key to remove.</param>
84 <exception cref="T:System.Collections.Generic.KeyNotFoundException">Thrown if the key is not found.</exception>
85 <exception cref="T:System.IO.IOException">Thrown when the method failed due to an internal I/O error.</exception>
88 bool exists = Preference.Contains("active_user");
91 string value = Preference.Remove("active_user");
96 <member name="M:Tizen.Applications.Preference.RemoveAll">
98 Removes all the key-value pairs from the preference.
100 <exception cref="T:System.IO.IOException">Thrown when the method failed due to an internal I/O error.</exception>
103 Preference.Set("Option_enabled", true);
104 Preference.Set("active_user", "Joe");
105 Preference.Set("default_volume", 10);
106 Preference.Set("brightness", "0.6");
107 Preference.RemoveAll();
111 <member name="T:Tizen.Applications.Preference.EventContext">
113 The class manages event handlers of the preference keys. The class enables having event handlers for individual preference keys.
116 <member name="E:Tizen.Applications.Preference.EventContext.Changed">
118 Occurs whenever there is a change in the value of a preference key.
120 <exception cref="T:System.ArgumentException">Thrown when the key does not exist or when there is an invalid parameter.</exception>
121 <exception cref="T:System.InvalidOperationException">Thrown when the bundle instance has been disposed.</exception>
124 private static void Preference_PreferenceChanged(object sender, PreferenceChangedEventArgs e)
126 Console.WriteLine("key {0}", e.Key);
128 Preference.EventContext context = null;
129 Preference.GetEventContext("active_user").TryGetTarget(out context);
132 context.Changed += Preference_PreferenceChanged;
135 Preference.Set("active_user", "Poe");
137 Preference.GetEventContext("active_user").TryGetTarget(out context);
140 context.Changed -= Preference_PreferenceChanged;
145 <member name="T:Tizen.Applications.PreferenceChangedEventArgs">
147 This class is an event argument of the PreferenceChanged event.
150 <member name="P:Tizen.Applications.PreferenceChangedEventArgs.Key">
152 The key of the preference whose value is changed.