You can use a class PackageInfo. Sort of:
PackageInfo myInfo;
myInfo = getPackageManager().getPackageInfo(getPackageName(), 0)
version = myInfo.versionName;
getPackageName()returns the full name of your package (the one that called it). If you searched for version information in another package, you can wrap it in a block try {...} catchif the package you were looking for was not installed. Here is an example of this here .
source
share