Translate this page

How to get Android App Version Programmatically in Java Android Studio

Here is how to get android app current version code programmatically in java android

Sometimes, you will need get the current version number of your android app programmatically, this can be useful to display the current version of your app to your users because when you update your app, you can just pass the version string to a textview to display it instead of editing your strings.xml file each time when you do an update.


Here is the code

String versionName = BuildConfig.VERSION_NAME;

With this code above, you can now pass the string to a textview

Here is the full code that i use, i just catch the exception, it may not important.

try {


         String versionName = BuildConfig.VERSION_NAME;

         TextView txt = (TextView) findViewById(R.id.txtv);
         txt.setText("Version:" + versionName);
     }catch (Exception e){
         e.printStackTrace();
     }

Just create a textview and replace txtv id with its id

Related Posts

Here is How to Get Host Domain from URL in Android Java

Sometimes, we might need extract domain name such as www.google.com from the www.google.com/search=searchQuery. In android java, the code below can do it. It will output only the…

Android SoftKeyBoard Enter Key Handling

How to Handle Android Keyboard’s Enter Key to Support your Own Function By default, android soft keyboard’s enter key doesn’t support your own function even if you…

Test Intent and URL Schemes of Android Webview

URL Schemes Tester This page contains different URL Schemes that can be used to test various URL Schemes, it was created to test android webview, but other…

Realme XT Specifications, Launch Date, Price and Details

Realme xt details, launch date and reviews The Realme XT is an android smartphone with a massive 64 Mega pixels camera and qualcomm snapdragon 712 processor. Brand…

How to Copy a Webview Link in Android Java

Here is how to Copy current web address url in Android Java With the simple java code below, you can copy a link of current loaded website…

Fix Namespace ‘ads’ not bound in Android Studio Xml Java

Here is how to Fix Namespace ‘ads’ not bound in Android Studio This error is commonly appeared in the xml of your activity while you trying to…

This Post Has 2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *