Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2009

    Question How to confirm SetPreferenceForKey() is actually working correctly

    Can't get SetPreferenceForKey() and preferenceForKey() to work.

    Save function:-

    function saveString( ) {
    var myString = 'This is a test string';
    widget.setPreferenceForKey(myString, "key");
    alert("String saved.");

    Load function:-

    function loadString() {
    alert("Getting saved string.");

    var savedString = widget.preferenceForKey("key");
    if (savedString != null) {
    document.getElementById("txt").value = savedString;

    <a href="#" onclick="saveString()">save text</a>
    <a href="#" onclick="loadString()">load text</a>
    <p id="txt">This should get replaced.</p>

    I click the link to save a string, (get an alert looks like it's working) then click the link to get it and write to txt div, (get alert to say getting saved string) but nothing gets written.

    If I stick an alert after the if (savedString != null) syntax again, nothing happens suggesting the key / value isn't saved???

    I have no idea why this isn't working?

    using aptana.

    Any help would be really appreciated.

  2. #2
    Regular Contributor
    Join Date
    Jun 2009

    Re: How to confirm SetPreferenceForKey() is actually working correctly


    replace line:

    document.getElementById("txt").value = savedString;


    document.getElementById("txt").innerHTML = savedString;


Similar Threads

  1. NOKIA PBX 22 and RS232 not working correctly
    By Corrado9 in forum PC Suite API and PC Connectivity SDK
    Replies: 2
    Last Post: 2006-08-28, 04:29
  2. GDBSTUB working with BT?!?
    By BobbeeTec in forum Bluetooth Technology
    Replies: 6
    Last Post: 2006-01-25, 14:10
  3. on emulator working, on ngage isn't working
    By bojkar in forum Symbian
    Replies: 4
    Last Post: 2005-09-21, 17:15
  4. sendRedirect not working
    By nicole_yap in forum Mobile Java General
    Replies: 0
    Last Post: 2005-09-16, 03:35
  5. Replies: 1
    Last Post: 2002-12-31, 18:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts