Alex Rivera | Logout

Finding app version number in code

Asked 2010-05-21T11:37:13.107
23

Is there a simple way to find the current version of my application from within it? I would like to add the version string to the about screen.

Edit
Report

1 Answer

46

You should check this question.

I am doing it this way:

try {
            String pkg = mContext.getPackageName();
            mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName;
        } catch (NameNotFoundException e) {
            mVersionNumber = "?";
        }
answered 2010-05-21T11:51:09.827

Your Answer