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
Visitor
isantolin
Posts: 1
Registered: ‎10-01-2012
My Device: 9300
My Carrier: Movistar

Storage Using BlackBerry OS 5.0

How i can Storage data on WebWorks app using Blackberry OS 5.0 ?

Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Storage Using BlackBerry OS 5.0

in OS5.0 you can not use LocalStorage, so cookies is one possibility.

You can also check google gears, it brings some more functionality, I'm not sure if some sort of localstorage is included.

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Developer
The_Anomaly
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: Storage Using BlackBerry OS 5.0

Have you seen this:

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

 

Its for BB5+

If it helped you, click like. :smileyhappy:
Please use plain text.
Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer
My Carrier: n/a

Re: Storage Using BlackBerry OS 5.0

[ Edited ]

I would recommend writing a small gears wrapper - that exposes a local storage interface but uses gears underneath. Something along the lines of:

 

(function()
{
	if (!window.localStorage && google.gears)
	{
		var db = google.gears.factory.create('beta.database');
		db.open('BackboneLocalData');
		db.execute("CREATE TABLE IF NOT EXISTS persist_data (key TEXT UNIQUE NOT NULL PRIMARY KEY, value TEXT NOT NULL)").close();

		var localStorage =
			{
				clear: function ()
				{
					db.execute('begin').close();
					db.execute("DELETE FROM persist_data").close();
					db.execute('commit').close();
				},
				setItem: function (key, value)
				{
					db.execute('begin').close();
					db.execute("delete from persist_data where key = ?", [key]).close();
					db.execute("insert into persist_data(key, value) VALUES (?, ?)", [key, value]).close();
					db.execute('commit').close();
				},
				getItem: function (key)
				{
					db.execute('begin').close();
					r = db.execute("SELECT value FROM persist_data WHERE key = ?", [key]);
					ret = r.isValidRow() ? r.field(0) : null;
					r.close();
					db.execute('commit').close();
					return ret;
				}
			};

		window.localStorage = localStorage;
	}
})();

 One small issue with the above script: you wont be able to use square brackets with local storage. Iow you have to go localStorage.getItem("somekey") rather than localStorage["somekey"].

Please use plain text.
New Contributor
Racum
Posts: 3
Registered: ‎05-09-2013
My Device: Curve 9300
My Carrier: +55 11 986321037

Re: Storage Using BlackBerry OS 5.0

All OS 5.x and some 6.x versions don't support localStorage, try my polyfill:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Using-localStorage-for-pre-OS-6-...

 

[]'s

Racum

Please use plain text.