Browse Source

Create Class UserStore for save data where user login.

pull/3/head
Mushegh Sahakyan 4 years ago
parent
commit
cf0745034b
1 changed files with 36 additions and 0 deletions
  1. +36
    -0
      ui/src/main/java/com/wireguard/android/util/UserStore.java

+ 36
- 0
ui/src/main/java/com/wireguard/android/util/UserStore.java View File

@@ -0,0 +1,36 @@
package com.wireguard.android.util;

import android.content.Context;
import android.content.SharedPreferences;

public class UserStore {
private static UserStore instance;
private SharedPreferences sharedPreferences;
private static final String USER_SHARED_PREF = "com.wireguard.android.util.bubbleUserSharedPref";
private static final String USER_RESPONSE = "com.wireguard.android.util.bubbleUserResponse";

public static UserStore getInstance(Context context) {
if (instance == null) {
synchronized (UserStore.class) {
if (instance == null) {
instance = new UserStore(context);
}
}
}

return instance;
}

private UserStore(Context context) {
sharedPreferences = context.getSharedPreferences(USER_SHARED_PREF, Context.MODE_PRIVATE);
}

public void setUserResponse(String response) {
sharedPreferences.edit().putString(USER_RESPONSE, response).apply();
}

public String getUserResponse() {
return sharedPreferences.getString(USER_RESPONSE, "-1");
}

}

Loading…
Cancel
Save