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
Highlighted
New Developer
Posts: 8
Registered: ‎06-01-2011
My Device: Z30
My Carrier: .
Accepted Solution

Generating RuntimeStore ID. Why and how?

Hi,

I'm developing for API 5.0+, java.

I am confused about RuntimeStore ID. I've read that
- it should be unique and can be generated with eclipse, right click, etc.....
- I can use any number I like

I tried my application on simulators and it worked fine, but when I tried it on a real device then RuntimeStore returned and object that was not put there by me (it returned a NoMoreTransportsException object. ), so I hought I used a non unique ID, probably. I changed it and now it works OK.

My questions
1. The ID should be unique in the application or in the system?
- If only for the app, then why not to use just a simple serial as 1,2,3,...
- If only for the app, then why was there an object in the RuntimeStore for that ID I used? (as I mentioned above)
- If for the system, then how can be sure, that the generated ID is really unique? (Long datatype cannot hold a real GUID)

2. If I would like to put a String to RuntimeStore, how to generate a unique ID? Someone said I should use the fully qualified name of the class, so Eclipse generated hash for java.lang.String is 0xd4e2de8aa7759716L, right?

- In this case if the id should be system unique, what happens if an other application is already using this ID, because it was generated the same way (java.lang.String -> 0xd4e2....)


Thank you!
Zsolt
 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Generating RuntimeStore ID. Why and how?

the generated id should be unique. It is not guaranteed, but very very unlikely that the same id is already in use. read about the background of guid if you want to know the numbers.

of course the generation converts a string into long, if you take the same string you get the same number, so take care that your string is unique. i usually use my package name plus something that defines the string.
----------------------------------------------------------
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.
@SimonHain on twitter
New Developer
Posts: 8
Registered: ‎06-01-2011
My Device: Z30
My Carrier: .

Re: Generating RuntimeStore ID. Why and how?

1. So the ID should be SYSTEM UNIQUE and it is not a good idea to use for example 'java.lang.String' as a base string for the hash

2. By the way a real GUID consists of 16 bytes, while this ID is just 8 bytes

 

Thanks!

 

 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Generating RuntimeStore ID. Why and how?

1. yes
2. its used system-wide, not globally, so no need for the G in front of UID.
----------------------------------------------------------
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.
@SimonHain on twitter