diff --git a/app/src/main/java/net/foucry/pilldroid/PrefManager.java b/app/src/main/java/net/foucry/pilldroid/PrefManager.java index 637d4d1..cbd6736 100644 --- a/app/src/main/java/net/foucry/pilldroid/PrefManager.java +++ b/app/src/main/java/net/foucry/pilldroid/PrefManager.java @@ -10,29 +10,35 @@ import android.content.SharedPreferences; public class PrefManager { SharedPreferences pref; SharedPreferences.Editor editor; - Context _context; // shared pref mode int PRIVATE_MODE = 0; // Shared preferences file name - private static final String PREF_NAME = "androidhive-welcome"; - + private static final String PREF_NAME = "Pildroid-Prefs"; private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch"; + private static final String DATABASE_VERSION = "DatabaseVersion"; public PrefManager(Context context) { - this._context = context; - pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE); - editor = pref.edit(); + pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE); } public void setFirstTimeLaunch(boolean isFirstTime) { + editor = pref.edit(); editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime); - editor.commit(); + editor.apply(); + } + + public void setDatabaseVersion(int version) { + editor = pref.edit(); + editor.putInt(DATABASE_VERSION, version); + editor.apply(); } public boolean isFirstTimeLaunch() { return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true); } - + public int getDatabaseVersion() { + return pref.getInt(DATABASE_VERSION, 0); + } }