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
AbeesMuhammed
Posts: 49
Registered: ‎05-20-2009
My Device: Not Specified

GUID

Hi ,

 

Is there any API in BlackBerry that can give GUID or any Globally unique string?.its very Urgent

 

thanks

Please use plain text.
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: GUID

In JDE, you can select any string and on right click you will get option to convert this string into long.

 

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

 

 

Deepesh Gupta
Please use plain text.
Developer
AbeesMuhammed
Posts: 49
Registered: ‎05-20-2009
My Device: Not Specified

Re: GUID

Hi Deepesh,

 

Perhaps I din't get you right. At run time when I am about to store some data into the local database in the device I would like to generate a GUID which should be globally unique. The generated GUID will be used for the identity coloum in the local database table. It should be globally unique because the local database will have to be synced with the Server database.

 

Thanks

Abees

Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: GUID

Check this class in RIM API javadocs:

 

net.rim.device.api.synchronization.UIDGenerator

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: GUID

UIDGenerator will generate the unique one on device, we can't predict the same will not be generated on other device.

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: GUID

Combine Device PIN and GUID from UIDGenerator.

 

And this code will be 100% unique.

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: GUID

Just Perfect.

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
filiussoft
Posts: 106
Registered: ‎06-18-2009
My Device: Bold

Re: GUID

I used the UUID implementation found here (version 2.1.5) and changed a few things to make it J2ME compatible. 

 

I replaced the part where he uses the MAC address with the IMEI number and also used UIDGenerator. 

 

Not sure if it is the best solution but I am fairly certain it generates globally unique ids.  I mainly use them because the backend database uses GUIDs and it makes it easy for sync.

 

 

static { String imeiNumber = null; byte[] imeisv = GPRSInfo.getIMEISV(); imeiNumber = GPRSInfo.imeisvToString(imeisv, false); if (imeiNumber != null) { clockSeqAndNode |= Hex.parseLong(imeiNumber); // Uses IMEISV for Mac Address replacement

} else { clockSeqAndNode |= UIDGenerator.makeLUID(UIDGenerator.getUniqueScopingValue(), UIDGenerator.getUID()); // Uses the UIDGenerator for Mac Address replacement } // Skip the clock sequence generation process and use random instead. clockSeqAndNode |= (long) (UIDGenerator.makeLUID(UIDGenerator.getUniqueScopingValue(), UIDGenerator.getUID()) * 0x3FFF) << 48; }

 

----
If this helped you, press the thumbs up button (on the far right - '+' thumb icon)
If this post solved the issue, click "Accept as Solution"
Please use plain text.
New Member
bhaskar712
Posts: 1
Registered: ‎07-21-2011
My Device: blackberry curv
My Carrier: Airtel

Re: GUID

Hi,

 

Can you guide me ... how to generate the UUIDs in J2ME...can you share the code.. classes?

 

Bhaskar

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: GUID

Does this help?

 

javax.bluetooth.UUID

Please use plain text.