question: private static void loadPackageData ( Context context ) { if ( context != null ) { try { PackageManager packageManager = context . getPackageManager ( ) ; PackageInfo packageInfo = packageManager . getPackageInfo ( context . getPackageName ( ) , 0 ) ; Constants . APP_PACKAGE = packageInfo . packageName ; Constants . APP_VERSION = "" + packageInfo . versionCode ; Constants . APP_VERSION_NAME = packageInfo . versionName ; int buildNumber = loadBuildNumber ( context , packageManager ) ; if ( ( buildNumber != 0 ) && ( buildNumber > packageInfo . versionCode ) ) { Constants . APP_VERSION = "" + buildNumber ; } } catch ( Exception e ) { Log . e ( TAG , "Exception thrown when accessing the package info:" ) ; e . printStackTrace ( ) ; } } }
target:  Helper method to set the package name and version code. If an exception occurs, these values will be null!