Created
September 12, 2014 13:58
-
-
Save Joisar/8a00d459b162ac9a1a1a to your computer and use it in GitHub Desktop.
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
public class PrefsManager { | |
// Shared Preferences | |
private SharedPreferences pref; | |
// Editor for Shared preferences | |
private Editor editor; | |
// Shared pref mode | |
private int PRIVATE_MODE = 0; | |
// Sharedpref file name | |
private static final String PREF_NAME = "App_Name"; | |
// Keys | |
public static final String KEY_IS_LOGGED_IN = "IS_LOGGED_IN"; | |
public static final String KEY_FTP_USERNAME = "FTP_USERNAME"; | |
public static final String KEY_FTP_PASSWORD = "FTP_PASSWORD"; | |
public static final String KEY_FTP_HOST = "FTP_HOST"; | |
public static final String KEY_FTP_DIRECTORY = "FTP_DIRECTORY"; | |
// Constructor | |
public PrefsManager() { | |
} | |
public void getPrefs(Context mContext) { | |
pref = mContext.getSharedPreferences(PREF_NAME, PRIVATE_MODE); | |
} | |
public void editPrefs() { | |
editor = pref.edit(); | |
} | |
public void commitPrefs() { | |
editor.commit(); | |
} | |
public void putBoolean(String key, boolean value) { | |
editor.putBoolean(key, value); | |
} | |
public boolean getBoolean(String key, boolean default_value) { | |
return pref.getBoolean(key, default_value); | |
} | |
public void putString(String key, String value) { | |
editor.putString(key, value); | |
} | |
public String getString(String key, String default_value) { | |
return pref.getString(key, default_value); | |
} | |
public void putInt(String key, int value) { | |
editor.putInt(key, value); | |
} | |
public int getInt(String key, int default_value) { | |
return pref.getInt(key, default_value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment