Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding app version number in code

Is there a simple way to find the current version of my application from within it? I would like to add the version string to the about screen.

like image 459
themaninthesuitcase Avatar asked May 21 '10 11:05

themaninthesuitcase


2 Answers

You should check this question.

I am doing it this way:

try {             String pkg = mContext.getPackageName();             mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName;         } catch (NameNotFoundException e) {             mVersionNumber = "?";         } 
like image 166
Macarse Avatar answered Sep 21 '22 17:09

Macarse


please try out this.

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); version = pInfo.versionName; 
like image 32
mita Avatar answered Sep 18 '22 17:09

mita