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

Java Development

Reply
Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified
Accepted Solution

Question about RuntimeStore

I've a question regarding RuntimeStore.

The API documentation says it is "a central location for applications to share information". But does this mean that there are no cached instances of the objects stored there?

For example:

 

 

Integer i = new Integer(0);
RuntimeStore.getInstance().put(ID, i);
i.setValue(7);

//On other module:
Integer i = (Integer) RuntimeStore.getInstance().get(ID);

 

 

What will be the value of i? It is necesary to call replace after each modification of the object in order to be inmediately visible to other modules?

 

And if I have my own cached Integer, is that object refreshed when some other module alters it, withouth having to call  getInstance().get(ID)?

 

Thanks.

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Question about RuntimeStore

"i" will be 7. RuntimeStore keeps references to the object so if you modify the reference, other applications will see the changes. replace would be to change the object, such as from Integer to Float. At least that is from my experence.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Question about RuntimeStore

Agree with rcmaniac25 and just to add a little.

 

Each Application will get a reference to the Object, so they will all see the same Object,  Thus updates will be seen by all.  If you create a new Object and replace, then the Object is no longer shared.  Everyone will have to get the reference from RuntimeStore again.

Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Question about RuntimeStore

I see. So RuntimeStore must be something like a shared area of RAM.

Thanks, peter and rcmaniac25.