15

In the Android manifest file, there is a field that specifies the application version.

How I can read that value programmatically?

3 Answers 3

36

You can get access to that information through the PackageInfo class:

PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
Log.d("pinfoCode",pinfo.versionCode);
Log.d("pinfoName",pinfo.versionName);
Sign up to request clarification or add additional context in comments.

Comments

1

Call GetApplicationContext().PackageManager().getPackageInfo(). The PackageInfo object it returns will have what you need.

Comments

0
try {
    final String packageName = context.getPackageName();
    PackageInfo packageInfo = context.getApplicationContext().getPackageManager().getPackageInfo(packageName, 0);
    final int iconid = packageInfo.applicationInfo.icon; // for example

    // etc
} catch (android.content.pm.PackageManager.NameNotFoundException e) {}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.