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

Posts: 281
Registered: ‎05-31-2012
My Device: Playbook
My Carrier: o2
Accepted Solution

What is the best way to save a array of Objects and then load it?

Hi, what is the best way to save and load a array of Objects?


I hade a code like this, but it does not work:

var test = new Array();
test.push(new Foo("a"));
for (var i = 0; i < test.length; i++) {
// save and load, then show again
localStorage.setItem("test", test);
var test2 = localStorage("test");
for (var i = 0; i < test2.length; i++) {

 the problem is, in the first log I get the things I want. The second time I get:

Uncaught TypeError: Property 'localStorage' of object [object Object] is not a function 


Plase "+Like" my post if it was helpful.
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: What is the best way to save a array of Objects and then load it?

The work around to this problem is to stringify before saving and then parse before loading.


Though I've been told it's much better to use IndexDB.
co-founder of Diaree | BB Dev for PictureThis