Created
August 21, 2013 18:16
-
-
Save snadjafi/6298002 to your computer and use it in GitHub Desktop.
persistent model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kuapay.library.helperClass; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
public class DefaultTipHelper | |
{ | |
//region Constant Variables | |
private static final String TIP_SETTING = "tip_setting"; | |
private static final String DEFAULT_TIP = "0"; | |
private final String email; | |
//endregion | |
//region Variables | |
private final SharedPreferences tipSettingsSharedPreferences; | |
private final SharedPreferences.Editor editor; | |
//endregion | |
//region Constructors | |
public DefaultTipHelper(Context context, String email) | |
{ | |
tipSettingsSharedPreferences = context.getSharedPreferences(TIP_SETTING, 0); | |
editor = tipSettingsSharedPreferences.edit(); | |
this.email = email; | |
} | |
//endregion | |
//region Getters | |
public String getTip() | |
{ | |
String tip = tipSettingsSharedPreferences.getString(email,null); | |
if (tip == null) | |
{ | |
editor.putString(email, DEFAULT_TIP).commit(); | |
return DEFAULT_TIP; | |
} | |
return tip; | |
} | |
//endregion | |
//region Setters | |
public void setTip(String tip) | |
{ | |
editor.putString(email, tip).commit(); | |
} | |
//endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment