org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-DF4D8745-B6D4-4BC4-AF2D-0F71F28E9F27.html
author tasneems@symbian.org
Fri, 05 Mar 2010 19:11:15 -0800
changeset 229 716254ccbcc0
permissions -rw-r--r--
Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable


<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="mobileconcept"/><meta name="DC.Title" content="setPreferenceForKey()"/><meta name="DC.Relation" scheme="URI" content="GUID-E8E82EBC-05E6-49A2-9451-BF02986BCEE8"/><meta name="DC.Relation" scheme="URI" content="GUID-EFCCE3CA-A1D2-4CD0-8D10-BD6320B19E5A"/><meta name="DC.Relation" scheme="URI" content="GUID-7C69DDA4-16F1-4A8F-BDB2-4CB0015B4E81"/><meta name="DC.Relation" scheme="URI" content="GUID-6CD2776F-A868-4280-967F-4EB426212556"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-DF4D8745-B6D4-4BC4-AF2D-0F71F28E9F27"/><title>setPreferenceForKey() </title><script type="text/javascript">
      function initPage() {}
    </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-DF4D8745-B6D4-4BC4-AF2D-0F71F28E9F27">setPreferenceForKey()</h1><div>
<p><strong>Description:</strong></p>
<p>The <code>setPreferenceForKey</code> method allows a key to be stored along with its associated preference. The arguments are like name and value pairs. The preference value for the key is stored persistently, so if the widget or device is restarted, the value is retained. However, the values stored by a widget are removed when a widget is uninstalled from the device. This includes the case when a widget is reinstalled; where the old widget is uninstalled, the new widget is installed.</p>
<p>An existing preference can be overwritten with a new value by simply calling the method with the same key and new value.</p>
<p>A stored preference for a key can be removed by calling the method with the <code>preference</code> argument set to <code>null</code></p>
<p><strong>Syntax:</strong></p>
<pre class="codeblock" id="GUID-4109BCAA-7A09-4A6F-81DC-57C4F61D23AA">[void] window.widget.setPreferenceForKey(String preference, String key) </pre>
<p>or</p>
<pre class="codeblock" id="GUID-4C30EE7C-0698-4673-A5F1-500D04B16C24">[void] widget.setPreferenceForKey(String preference, String key)</pre>
<p><strong>Arguments:</strong></p>
<ul>
<li><p><code>preference</code>:</p>

<p>A text string specifying a reusable value to be stored.</p>

</li>
<li><p><code>key</code>:</p>

<p>A short text string defined as the name of the preference to be stored.</p>

</li>
</ul>
<p><strong>Return value:</strong></p>
<p>This method does not return a value.</p>
<p><strong>Example code:</strong></p>
<pre class="codeblock" id="GUID-7CFF4DD7-6938-44FC-829E-624FB4792E8C">// Save the inputted Search key
var searchArg = document.forms[0].searchKey.value;
widget.setPreferenceForKey('searchKey',searchArg);</pre>
</div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html>