Wednesday 30 October 2013

How to get application version code and version name in android

Hi Friends,
It is very easy to get version code and version name of any android application programmatically.
This should be done using PackageInfo, See following example,

PackageManager pm=getApplicationContext().getPackageManager();
PackageInfo pi=pm.getPackageInfo(getApplicationContext().getPackageName(), 0);

System.out.println("Version Code="+pi.versionCode+"\n Version Name="+pi.versionName);

For more details Click Here

References:
PackageManager
PackageInfo


No comments:

Post a Comment