List of usage examples for android.content Context getSharedPreferences
public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);
From source file:Main.java
public static String getFbUsername(Context context) { SharedPreferences fbInfo = context.getSharedPreferences(FB_VARIABLES, 0); String username = fbInfo.getString(FB_NAME, ""); if (username.isEmpty()) { return ""; }//w ww . j a v a 2s.c om return username; }
From source file:Main.java
public static boolean checkAuthorization(Context context) { SharedPreferences tokenInfo = context.getSharedPreferences(PREF_NAME, 0); String token = tokenInfo.getString("oauth_token", null); String tokenSecret = tokenInfo.getString("oauth_token_secret", null); String verifier = tokenInfo.getString("oauth_verifier", null); return (token != null && tokenSecret != null && verifier != null); }
From source file:Main.java
public static void SetHasSeenBefore(String name, Context context) { SharedPreferences sharedPrefs = context.getSharedPreferences(prefCategoryName, Activity.MODE_PRIVATE); Editor editor = sharedPrefs.edit();//from www. ja v a 2 s . c o m editor.putBoolean(name, true); editor.commit(); }
From source file:Main.java
public static void clearDataAsOffLine(Context context) { SharedPreferences preferences = context.getSharedPreferences(PRFERENCE_NAME_SYT, Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear();//from w w w .j a v a 2 s.co m editor.commit(); // CacheFileUtil.reSetCacheDir(); }
From source file:Main.java
public static int getInt(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE); int value;//w w w .j a va 2 s .co m value = sp.getInt(key, -1); return value; }
From source file:Main.java
public static void setMsgFirstSyncKey(String targetId, Context context) { SharedPreferences preferences = context.getSharedPreferences("messageFirstSync" + targetId, Context.MODE_PRIVATE); SharedPreferences.Editor editor1 = preferences.edit(); editor1.putInt("targetId", 1); editor1.commit();//w w w . j a va2s . c o m }
From source file:Main.java
public static String getString(Context context, String key, String defaultValue) { return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE).getString(key, defaultValue); }
From source file:Main.java
public static String getString(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE); String value;//from ww w . ja v a 2s . co m value = sp.getString(key, ""); return value; }
From source file:Main.java
public static boolean isLoginFirst(Context context) { SharedPreferences fbInfo = context.getSharedPreferences(FB_VARIABLES, 0); String loginfirst = fbInfo.getString(IS_FIRST_TIME, "yes"); if (loginfirst.equals("yes")) { return true; }// w ww . j ava2 s . c o m return false; }
From source file:Main.java
/** * Gets the sound preferences//from w w w. ja v a 2 s . c o m * * @param context * @return */ public static boolean getSound(Context context) { SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); return settings.getBoolean(PREF_SOUND, true); }