In you AndroidManifest.xml file, you can specify the values of android:versionCode
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.
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