The AndroidManifest.xml contains the version name of the application, something like
AndroidManifest.xml
android:versionName=\"1.0\"
Now the quest
If you use ADT and Eclipse:
String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
If you use Gradle, there is an easier way, since it puts the data into BuildConfig for you:
String version = BuildConfig.VERSION_NAME;