Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SharedPreferences pref; // Shared Preferences reference
- Editor editor; // Editor reference for Shared preferences
- Context _context; // Context
- int PRIVATE_MODE = 0; // Shared preferences mode
- public static final String PREFER_NAME = "Session"; // Shared preferences file name
- public static final String IS_USER_LOGIN = "IsUserLoggedIn"; // Shared Preferences Keys
- public static final String KEY_USER = "User"; // Username
- public static final String KEY_PASS = "Pass"; // Password
- public static final String KEY_SIZE = "FontSize"; // Shared Preferences Keys
- public static final String KEY_COLOUR = "Colour"; // Username
- // Constructor
- public UserSession(Context context){
- this._context = context;
- pref = _context.getSharedPreferences(PREFER_NAME, PRIVATE_MODE);
- editor = pref.edit();
- }
- //Create login
- public void createLogin(String uName, String uPass){
- editor.putBoolean(IS_USER_LOGIN, true); // Storing login value as TRUE
- editor.putString(KEY_USER, uName);
- editor.putString(KEY_PASS, uPass);
- // commit changes
- editor.commit();
- }
- //Create login
- public void createUserSettings(String uSize, String uColour){
- editor.putString(KEY_SIZE, uSize);
- editor.putString(KEY_COLOUR, uColour);
- // commit changes
- editor.commit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement