Save last app version on preferences

This commit is contained in:
2016-03-04 08:43:58 -05:00
parent f41f877107
commit b4911b6cb4
2 changed files with 9 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ import android.util.DisplayMetrics;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import org.isoron.uhabits.BuildConfig;
public abstract class DialogHelper
{
@@ -59,6 +61,12 @@ public abstract class DialogHelper
prefs.edit().putInt("launch_count", count + 1).apply();
}
public static void updateLastAppVersion(Context context)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putInt("last_version", BuildConfig.VERSION_CODE).apply();
}
public static int getLaunchCount(Context context)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

View File

@@ -73,6 +73,7 @@ public class MainActivity extends ReplayableActivity
{
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
DialogHelper.incrementLaunchCount(this);
DialogHelper.updateLastAppVersion(this);
showTutorial();
new AsyncTask<Void, Void, Void>() {