×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    Question Problems with preferences

    I couldn't find information about this subject, I hope you can help me.

    I'm using the following code trying to save some settings, but I can't make it work, the web app just get stuck, or continues without giving me the alert:

    Here's what I have in the config.xml:
    Code:
    <preference name="user" readonly="false" value="User"/>
    Index.html:
    Code:
    <body onload="init();">
    code.js:
    Code:
    function init()
    {	
    	alert(widget.preferences['user']);
    }
    without that the web app works fine, the problems come when I add code for saving or loading preferences. I also tried widget.preferences.getItem('user'), and got the same results.


    Thanks in advance for your help

  2. #2
    Super Contributor
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,098

    Re: Problems with preferences

    Hello edua91 and welcome to the discussion boards!

    Try this:
    Add the following line to your config.xml, but do not remove any lines.

    Have it located below the " <feature name..." tag.

    <preference name="user" readonly="false" value="Marko"/>

    Then into your basic.js:

    function init()
    {
    alert(widget.preferences['user']);
    }
    </code>

    Then, run the preview. You should see "Marko" displayed and then below that "OK".

    Please compare this to what you have and see where the difference, hope this helps!

    Best,
    Marko
    [FONT="Comic Sans MS"][COLOR="Blue"][/COLOR][I]Marko Lumivuori
    Technical Support
    +358 40 8019330
    [email]marko.lumivuori@nokia.com[/email][/I][/FONT]

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    Re: Problems with preferences

    Hi Marko, thank you for your time, I tried your code on my project but it didn't work neither on the simulator nor the device, then I created a new project and just added your code, it worked on the simulator but not on the device =/, I'm using a X3-02 and a C3-00 for testing, both gave me the same results.

    Just for reference, the actual project is more complex than just giving the alert, i just post a simplified version of my problem, but it is weird that it didn't worked even on a new project with just that code

    Eduardo

  4. #4
    Registered User
    Join Date
    Mar 2012
    Posts
    2

    Re: Problems with preferences

    Hi, I tried same code it worked on the simulator (its stored for that particular application cycle and if i close the application and relaunch it , in that case i am not able to see the stored data) .
    However, documentation claims that i"widget.preferences" will store data in device permanent storage.

  5. #5
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Problems with preferences

    Quote Originally Posted by basker16 View Post
    Hi, I tried same code it worked on the simulator (its stored for that particular application cycle and if i close the application and relaunch it , in that case i am not able to see the stored data) .
    However, documentation claims that i"widget.preferences" will store data in device permanent storage.
    Hello and welcome to forum!

    There is a known issue about simulator local preview and setItem()/getItem() methods.
    For simulator, bracket access should be used to set/get preferences e.g. widget.preferences["key"] = "value";.

    Second thing that might cause this, is that preference is not declared in config.xml. So please check that you have
    <preference name="key" value=""/> in config.xml

    PS. as a third option. alert() is not supported is Series 40 Web Apps.

    Br,
    Ilkka

  6. #6
    Registered User
    Join Date
    Mar 2012
    Posts
    2

    Re: Problems with preferences

    hi Ilkka,
    thanks for your response.

    I forgot to mentioned in my previous post that the same (widget.preferences["key"] = "value"; and defining the 'Key' inside 'preferences' tag in config.xml) code I tried and it is not working.
    What I mean to say here is not working is it is not storing the data in device 'persistent memory' i.e. if I close the applciation and relaunch it.

    Can you please guide me to store data in persistent memory for S40 webapps?

  7. #7
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Problems with preferences

    I wrote a Wiki article about storing preferences: (feedback welcome ). Basically the steps you have taken, should be enough to make preferences work.
    http://www.developer.nokia.com/Commu...es_40_Web_Apps

    Could you check what Nokia Browser version is installed? (Options ->Tools -> About)
    If it is less than 1.5.x, I would recommend to download latest from http://download.browser.ovi.com/

    Br,
    Ilkka

  8. #8
    Registered User
    Join Date
    Jun 2008
    Location
    Port Elizabeth, South Africa
    Posts
    37

    Re: Problems with preferences

    Hi basker16,

    You have to run the web app from the Nokia Browser's Web App menu and not from the URL address bar. I encountered this problem before. Not sure why it treats the URL address bar differently. Maybe it is a bug in Nokia Browser.

    Your web app will appear in the Web App menu after the first run from the URL address bar.

    I hope that helps.

    Regards,
    Stephen

Similar Threads

  1. Problem with preferences.
    By rtf_const in forum Nokia Asha Web Apps
    Replies: 3
    Last Post: 2011-06-14, 11:15
  2. Replies: 3
    Last Post: 2009-10-02, 16:15
  3. Launching Preferences
    By inas in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2007-02-05, 08:36
  4. Preferences store
    By urrg in forum Symbian
    Replies: 1
    Last Post: 2004-11-26, 02:46
  5. user preferences
    By djazia in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2003-07-28, 15:02

Posting Permissions

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