mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Add new Pref, DATABASE_VERSION used to update or not the database.
This commit is contained in:
parent
2415696c82
commit
5b0a3c4655
1 changed files with 14 additions and 8 deletions
|
@ -10,29 +10,35 @@ import android.content.SharedPreferences;
|
||||||
public class PrefManager {
|
public class PrefManager {
|
||||||
SharedPreferences pref;
|
SharedPreferences pref;
|
||||||
SharedPreferences.Editor editor;
|
SharedPreferences.Editor editor;
|
||||||
Context _context;
|
|
||||||
|
|
||||||
// shared pref mode
|
// shared pref mode
|
||||||
int PRIVATE_MODE = 0;
|
int PRIVATE_MODE = 0;
|
||||||
|
|
||||||
// Shared preferences file name
|
// 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 IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
|
||||||
|
private static final String DATABASE_VERSION = "DatabaseVersion";
|
||||||
|
|
||||||
public PrefManager(Context context) {
|
public PrefManager(Context context) {
|
||||||
this._context = context;
|
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
||||||
pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
|
||||||
editor = pref.edit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstTimeLaunch(boolean isFirstTime) {
|
public void setFirstTimeLaunch(boolean isFirstTime) {
|
||||||
|
editor = pref.edit();
|
||||||
editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
|
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() {
|
public boolean isFirstTimeLaunch() {
|
||||||
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
||||||
}
|
}
|
||||||
|
public int getDatabaseVersion() {
|
||||||
|
return pref.getInt(DATABASE_VERSION, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue