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

Native Development

Posts: 26
Registered: ‎07-22-2012
My Device: Z10
My Carrier: Telstra
Accepted Solution

Extract version number from bar-descriptor.xml programatically

Is there a way to extract a version number and other information from bar-descriptor.xml file similar to how it's done in Android world via getPackageInfo() in PackageManager?


That'd be a handy way to play around those values in your code.



Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Extract version number from bar-descriptor.xml programatically

[ Edited ]

There are various platform apis that you can use such as the PackageInfo,




or ApplicationInfo,






If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Extract version number from bar-descriptor.xml programatically

Suns33k3r, since you asked in the Native SDK forum, perhaps you don't have access to Cascades APIs.

In that case you may want to just read from the app/META-INF/MANIFEST.MF file and parse it to find the "Package-Version" field.

I believe that's the real location for the version number used by the system. The bar-descriptor.xml file is used during packaging, but the version is extracted from there, combined with the buildId (if you didn't include all four parts) and then stored in the MANIFEST.MF file with other stuff.

There may be another place you can get it through the Native SDK using a proper API but I'm not aware of that.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Posts: 109
Registered: ‎08-23-2012
My Device: Blackberry Z10

Re: Extract version number from bar-descriptor.xml programatically

You can use ApplicationInfo class to find out application version like this


ApplicationInfo app_info;



Also you can use


PackageInfo pack_info;



This will return version in format. The first three portion contains package version and last one is the package build id.

Dharmender Singh