Android Open Source - EasyVote App Session Manager






From Project

Back to project page EasyVote.

License

The source code is released under:

Apache License

If you think the Android project EasyVote listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.llanox.mobile.easyvote;
//  ww w . j  a v  a  2s .co m
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class AppSessionManager {
  public static final String DISPLAY_NAME_KEY = "DISPLAY_NAME_KEY";

  public static final String NICKNAME_KEY = "NICKNAME_KEY";

  public static final String ID_USER_KEY = "ID_USER_KEY";
  
  public static final String SESSION_SETTINGS_PREF = "session_settings_pref";

  private static final String EMAIL_KEY = "EMAIL_KEY";
  

  public static void saveUserSession(Context ctx,String id, String nickName,String displayName,String email) {

    SharedPreferences pref = ctx.getSharedPreferences(SESSION_SETTINGS_PREF, Context.MODE_PRIVATE);
    Editor edit = pref.edit();
    edit.putString(ID_USER_KEY, id );
    edit.putString(NICKNAME_KEY, nickName);
    edit.putString(DISPLAY_NAME_KEY, displayName);
    edit.putString(EMAIL_KEY, email);  
    edit.apply();
    
  }
  
  public static void removeUserSession(Context ctx){
    SharedPreferences pref = ctx.getSharedPreferences(SESSION_SETTINGS_PREF, Context.MODE_PRIVATE);
    Editor edit = pref.edit();
    edit.clear();
    edit.apply();
  }
  
  public static String getUserID(Context ctx){
    SharedPreferences pref = ctx.getSharedPreferences(SESSION_SETTINGS_PREF, Context.MODE_PRIVATE);    
    return pref.getString(ID_USER_KEY, null);
  }
  
  public static String getUserEmail(Context ctx){
    SharedPreferences pref = ctx.getSharedPreferences(SESSION_SETTINGS_PREF, Context.MODE_PRIVATE);    
    return pref.getString(EMAIL_KEY, null);
  }
  
  
  
}




Java Source Code List

com.llanox.mobile.easyvote.AnswerQuestionDetailActivity.java
com.llanox.mobile.easyvote.AnswerQuestionDetailFragment.java
com.llanox.mobile.easyvote.AnswerQuestionListActivity.java
com.llanox.mobile.easyvote.AnswerQuestionListFragment.java
com.llanox.mobile.easyvote.AppCredentials.java
com.llanox.mobile.easyvote.AppSessionManager.java
com.llanox.mobile.easyvote.AskQuestion.java
com.llanox.mobile.easyvote.ConstantsEasyVote.java
com.llanox.mobile.easyvote.EntryPointActivity.java
com.llanox.mobile.easyvote.PlusBaseActivity.java
com.llanox.mobile.easyvote.QuestionDetailActivity.java
com.llanox.mobile.easyvote.QuestionDetailFragment.java
com.llanox.mobile.easyvote.QuestionListActivity.java
com.llanox.mobile.easyvote.QuestionListFragment.java
com.llanox.mobile.easyvote.data.DataException.java
com.llanox.mobile.easyvote.data.DataLayerManager.java
com.llanox.mobile.easyvote.data.DataSession.java
com.llanox.mobile.easyvote.data.QuestionData.java
com.llanox.mobile.easyvote.data.UserData.java
com.llanox.mobile.easyvote.data.util.DateTimeUtils.java
com.llanox.mobile.easyvote.model.AnswerQuestion.java
com.llanox.mobile.easyvote.model.Question.java
com.llanox.mobile.easyvote.model.User.java