-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSharedPrefManager.java
55 lines (42 loc) · 1.48 KB
/
SharedPrefManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.ikai.unitshop;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by shiv on 18/11/17.
*/
class SharedPrefManager {
// Shared Preferences
private SharedPreferences pref;
// Editor for Shared preferences
private SharedPreferences.Editor editor;
// Shared pref mode
private int PRIVATE_MODE = 0;
// Sharedpref file name
private static final String PREF_NAME = "TrackUser";
// All Shared Preferences Keys
private static final String IS_Shop_Registered = "IsShopRegistered";
private static final String IS_ACCOUNT_DETAILS_FILLED = "IsAccountDetailsFilled";
// Constructor
SharedPrefManager(Context context){
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
editor = pref.edit();
}
// Function to check whether shop is registered completely.
boolean isShopRegistered() {
return pref.getBoolean(IS_Shop_Registered, false);
}
// Function to check whether account details is filled or not.
boolean isAccountDetailsFilled() {
return pref.getBoolean(IS_ACCOUNT_DETAILS_FILLED, false);
}
// Function to set IS_ACCOUNT_DETAILS_FILLED to true.
void setAccountDetailsFilled() {
editor.putBoolean(IS_ACCOUNT_DETAILS_FILLED, true);
editor.commit();
}
// Function to set IS_Shop_Registered to true.
void setShopRegistered() {
editor.putBoolean(IS_Shop_Registered, true);
editor.commit();
}
}