Pilldroid/app/src/main/java/net/foucry/pilldroid/PrefManager.java

45 lines
1.3 KiB
Java
Raw Normal View History

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
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";
private static final String DATABASE_VERSION = "DatabaseVersion";
2021-01-22 21:16:41 +01:00
public PrefManager(Context context) {
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
2021-01-22 21:16:41 +01:00
}
public void setFirstTimeLaunch(boolean isFirstTime) {
editor = pref.edit();
2021-01-22 21:16:41 +01:00
editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
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);
}
public int getDatabaseVersion() {
return pref.getInt(DATABASE_VERSION, 0);
}
2021-01-22 21:16:41 +01:00
}