/**
* checks if the app is started for the first time (after an update).
* @return <code>true</code> if this is the first start (after an update)else <code>false</code>
*/
private boolean isUpdate(){
final int versionCode=Utils.getActualVersionCode(this);
final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
final long lastVersionCode=prefs.getLong(LAST_VERSION_CODE_KEY,0);
if (versionCode != lastVersionCode) {
Log.i(TAG,"versionCode " + versionCode + " is different from the last known version "+ lastVersionCode);
return true;
}
else {
Log.i(TAG,"versionCode " + versionCode + " is already known");
return false;
}
}

Example 7

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.