Add new Pref, DATABASE_VERSION used to update or not the database.

This commit is contained in:
jacques 2021-03-17 13:35:57 +01:00
parent 2415696c82
commit 5b0a3c4655

View file

@ -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);
}
}