Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User edua91's Avatar
    Join Date
    Jun 2011
    Posts
    2
    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 Maveric's Avatar
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,102
    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 edua91's Avatar
    Join Date
    Jun 2011
    Posts
    2
    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 basker16's Avatar
    Join Date
    Mar 2012
    Posts
    2
    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 Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    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 basker16's Avatar
    Join Date
    Mar 2012
    Posts
    2
    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 Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    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 sperelson's Avatar
    Join Date
    Jun 2008
    Location
    Port Elizabeth, South Africa
    Posts
    36
    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. Playing with preferences (trying to remove a preference key)
    By mepartoconmigo in forum Symbian Web Runtime
    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 C++
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved