From 2390a137b2d46f5753171c49c1ed3f065059021b Mon Sep 17 00:00:00 2001 From: jacques Date: Fri, 22 Jan 2021 21:16:41 +0100 Subject: [PATCH] Add PrefManager code --- .../net/foucry/pilldroid/PrefManager.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/src/main/java/net/foucry/pilldroid/PrefManager.java diff --git a/app/src/main/java/net/foucry/pilldroid/PrefManager.java b/app/src/main/java/net/foucry/pilldroid/PrefManager.java new file mode 100644 index 0000000..637d4d1 --- /dev/null +++ b/app/src/main/java/net/foucry/pilldroid/PrefManager.java @@ -0,0 +1,38 @@ +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; + 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 IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch"; + + public PrefManager(Context context) { + this._context = context; + pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE); + editor = pref.edit(); + } + + public void setFirstTimeLaunch(boolean isFirstTime) { + editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime); + editor.commit(); + } + + public boolean isFirstTimeLaunch() { + return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true); + } + + }