Click here to Skip to main content
13,003,102 members (56,804 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 23 Nov 2011

Get the versionCode and versionName of your Android app

, 23 Nov 2011
Rate this:
Please Sign up or sign in to vote.
The following trick tell you How to get the versionCode and versionName of your android app using code
In you AndroidManifest.xml file, you can specify the values of android:versionCode and android:versionName.


The versionCode is integer value used to easily differentiate between app versions.

App developers must increment this value when they release updates to their apps in Android Market, so it can determine if users are using an old version of the app, and offer them to update it.


The versionName is a string containing a regular "release version" as seen in other desktop applications, such as "1.4.5″ or "3.7″.

The versionName is just a "human readable" version code.

Accessing it

Here is how you can access these values in your application code:

PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
int versionNumber = pinfo.versionCode;
String versionName = pinfo.versionName;

This way, you can check which version of your app is being used, if you need to do something spesific with that information. Or you can make a small method that checks for new updates to the app.

You can also access other useful resources this way, for example: packageName and requestedPermissions.

More on android app versioning here, and AndroidManifest i explained in depth here[^].


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...


Comments and Discussions

QuestionUpdate Pin
Member 1112095018-Apr-15 3:44
memberMember 1112095018-Apr-15 3:44 
Questionmy problem Pin
reza kia23-Jan-12 4:23
memberreza kia23-Jan-12 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170626.1 | Last Updated 23 Nov 2011
Article Copyright 2011 by Jaydeep Jadav
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid