public static void resetIfAppVersionChanged ( Context context ) { SharedPreferences prefs = getSharedPreferences ( context ) ; int appVersionCode = Integer . MIN_VALUE ; final int previousAppVersionCode = prefs . getInt ( PREF_KEY_APP_VERSION_CODE , Integer . MIN_VALUE ) ; try { appVersionCode = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) . versionCode ; } catch ( PackageManager . NameNotFoundException e ) { Log . w ( TAG , "Occurred PackageManager.NameNotFoundException" , e ) ; } if ( previousAppVersionCode != appVersionCode ) { SharedPreferences . Editor prefsEditor = prefs . edit ( ) ; prefsEditor . putLong ( PREF_KEY_APP_LAUNCH_COUNT , 0 ) ; prefsEditor . putLong ( PREF_KEY_APP_THIS_VERSION_CODE_LAUNCH_COUNT , 0 ) ; prefsEditor . putLong ( PREF_KEY_APP_FIRST_LAUNCHED_DATE , 0 ) ; prefsEditor . putInt ( PREF_KEY_APP_VERSION_CODE , Integer . MIN_VALUE ) ; prefsEditor . putLong ( PREF_KEY_RATE_CLICK_DATE , 0 ) ; prefsEditor . putLong ( PREF_KEY_REMINDER_CLICK_DATE , 0 ) ; prefsEditor . putBoolean ( PREF_KEY_DO_NOT_SHOW_AGAIN , false ) ; prefsEditor . commit ( ) ; } }
Reset saved conditions if app version changed .