Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Store user preferences in a HTML5 WebWorks app

I'm developing a HTML5 Webworks application for Blackberry OS 5+.

 

I have to sotre user name and password and I don't know how.

 

How can I do it?

Please use plain text.
Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Store user preferences in a HTML5 WebWorks app

useLocalstorage

.

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Please use plain text.
Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Store user preferences in a HTML5 WebWorks app

like following example

 

 /*
 * setValue()
 * Saving the value to the persistent storage
 * @param key : key for the value
 * @param value : value to be stored
 */
function setValue(key, value) {
    //saves to the persistent storage, "key", "value"
    localStorage.setItem(key, value);
}

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Please use plain text.
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Store user preferences in a HTML5 WebWorks app

[ Edited ]

And what happens if local storage is not available? Is local storate available on all Blackberry OS 5+ device?

Please use plain text.
Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Store user preferences in a HTML5 WebWorks app

 If u aware with phonegap /webworks than u needs to write you own plug-in for that because I feel sqlite api in WebWorks support with OS6+
https://developer.blackberry.com/html5/apis/bb_index.html

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Please use plain text.
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Store user preferences in a HTML5 WebWorks app

Is there another approach? I need to store user email, password and language settings.
Please use plain text.
Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Store user preferences in a HTML5 WebWorks app

I don't think so. I feel u must be using webworks than why don’t u write you own plug-in for that

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Please use plain text.
Developer
VansFannel
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Store user preferences in a HTML5 WebWorks app

Because I don't know how to do it.

Thank you very much for your help.
Please use plain text.
Developer
squished18
Posts: 289
Registered: ‎10-17-2008
My Device: Torch 9800
My Carrier: Rogers

Re: Store user preferences in a HTML5 WebWorks app

Would storing it in a SQLite database work for you? On PB the database is encrypted but on BB I believe the database file is accessible by anyone.

 

Cheers,

feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Regular Contributor
BertKoor
Posts: 81
Registered: ‎03-09-2012
My Device: PlayBook & Bold 9780
My Carrier: n/a

Re: Store user preferences in a HTML5 WebWorks app

[ Edited ]

> And what happens if local storage is not available?

You'll have to test that. Most likely an exception is thrown, you can catch that if you like.

 

> Is local storate available on all Blackberry OS 5+ device?

https://developer.blackberry.com/html5/apis/localstorage.html

So nope, OS6 and above only.

You really wanna bother with supporting old devices?

There's loads of other stuff not working the same on OS5 devices.

For instance HTML code is slightly different, not fully supporting HTML5.

 

NB: you can also try the good old traditional browser cookie approach, since WebWorks apps do run in sort of a browser.

Alternatively HTML5 Database is available in OS5+ for storage also.

https://developer.blackberry.com/html5/apis/database.html

I think LocalStorage is a very simplified API to the same thing: key & value storage only.

Please use plain text.