Blame view

footsafety/app/src/main/java/etelligens/com/foodsafety/utils/LangPrefData.java 796 Bytes
f7a13682   “wangming”   项目初始化
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
  package etelligens.com.foodsafety.utils;
  
  import android.content.Context;
  import android.content.SharedPreferences;
  import static etelligens.com.foodsafety.utils.Keyword.PREF_LANG;
  import static etelligens.com.foodsafety.utils.Keyword.PREF_NAME;
  
  public class LangPrefData {
      SharedPreferences pref;
      SharedPreferences.Editor edit;
      Context context;
  
      public LangPrefData(Context context) {
          this.context = context;
          pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
          edit = pref.edit();
      }
  
      public void setCurrentLanguage(String language) {
          edit.putString(PREF_LANG, language);
          edit.commit();
          edit.apply();
      }
  
      public String getCurrentLanguage() {
          return pref.getString(PREF_NAME, "en");
      }
  }