Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { @Deprecated public static boolean isUpdate(Context context, String newVersionName) { PackageManager manager = context.getPackageManager(); try { PackageInfo packageInfo = manager.getPackageInfo(context.getPackageName(), 0); String oldVersionName = packageInfo.versionName; if (oldVersionName.compareTo(newVersionName) < 0) return true; } catch (Exception e) { e.printStackTrace(); } return false; } public static boolean isUpdate(Context context, int newVersionCode) { PackageManager manager = context.getPackageManager(); try { PackageInfo packageInfo = manager.getPackageInfo(context.getPackageName(), 0); int oldVersionCode = packageInfo.versionCode; if (oldVersionCode < newVersionCode) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; } }