android - packageInfo.versionCode always return 1 -
If I change Manifest.xml from version 1 to 2, then Package Infocationcode always returns 1. I want to go back to 2, where should I fix it? Incidentally, packageInfo.versionName returns 1.0 in this case.
PackageManager packageManager = getContext (). GetPackageManager (); Try {PackageInfo packageInfo = packageManager.getPackageInfo (getContext). GetPackageName (), PackageManager.GET_ACTIVITIES); DB_VERSION = packageInfo.versionCode; Logs. V ("b", "+ + packageInfo.versionName");} hold (PackageManager.NameNotFoundException e) {e.printStackTrace ();} V ("a", "+ + package" Code> Manifest.xml
& nbsp; Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = " Com.example "android: versionCode =" 2 "Android: versionName =" 1.1 "& gt;
Change
PackageInfo package INFO = packageManager.getPackageInfo (GetContext (). GetPackageName (), PackageManager.GET_ACTIVITIES);
to
PackageInfo package INFO = packageManager.getPackageInfo (getContext (). GetPackageName (), 0);
Comments
Post a Comment