private static void loadPackageData(Context context){
  if (context != null) {
    try {
      PackageManager packageManager=context.getPackageManager();
      PackageInfo packageInfo=packageManager.getPackageInfo(context.getPackageName(),0);
      CrashConstants.APP_PACKAGE=packageInfo.packageName;
      CrashConstants.APP_VERSION="" + packageInfo.versionCode;
      CrashConstants.APP_VERSION_NAME=packageInfo.versionName;
      int buildNumber=loadBuildNumber(context,packageManager);
      if ((buildNumber != 0) && (buildNumber > packageInfo.versionCode)) {
        CrashConstants.APP_VERSION="" + buildNumber;
      }
    }
 catch (    PackageManager.NameNotFoundException e) {
      L.e("Exception thrown when accessing the package info:");
      e.printStackTrace();
    }
  }
}

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