2021-01-22 21:16:41 +01:00
|
|
|
package net.foucry.pilldroid;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Lincoln on 05/05/16.
|
|
|
|
*/
|
|
|
|
public class PrefManager {
|
|
|
|
SharedPreferences pref;
|
|
|
|
SharedPreferences.Editor editor;
|
|
|
|
|
|
|
|
// shared pref mode
|
|
|
|
int PRIVATE_MODE = 0;
|
|
|
|
|
|
|
|
// Shared preferences file name
|
2021-03-17 13:35:57 +01:00
|
|
|
private static final String PREF_NAME = "Pildroid-Prefs";
|
2021-01-22 21:16:41 +01:00
|
|
|
private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
|
2021-03-17 13:35:57 +01:00
|
|
|
private static final String DATABASE_VERSION = "DatabaseVersion";
|
2021-01-22 21:16:41 +01:00
|
|
|
|
|
|
|
public PrefManager(Context context) {
|
2021-03-17 13:35:57 +01:00
|
|
|
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
2021-01-22 21:16:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setFirstTimeLaunch(boolean isFirstTime) {
|
2021-03-17 13:35:57 +01:00
|
|
|
editor = pref.edit();
|
2021-01-22 21:16:41 +01:00
|
|
|
editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
|
2021-03-17 13:35:57 +01:00
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDatabaseVersion(int version) {
|
|
|
|
editor = pref.edit();
|
|
|
|
editor.putInt(DATABASE_VERSION, version);
|
|
|
|
editor.apply();
|
2021-01-22 21:16:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isFirstTimeLaunch() {
|
|
|
|
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
|
|
|
}
|
2021-03-17 13:35:57 +01:00
|
|
|
public int getDatabaseVersion() {
|
|
|
|
return pref.getInt(DATABASE_VERSION, 0);
|
|
|
|
}
|
2021-01-22 21:16:41 +01:00
|
|
|
}
|