List of usage examples for android.content SharedPreferences getString
@Nullable String getString(String key, @Nullable String defValue);
From source file:Main.java
public static void initialize(Activity activity) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); String orientation = prefs.getString("prefOrientation", "Null"); if ("Landscape".equals(orientation)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if ("Portrait".equals(orientation)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {/*w w w . j a v a2s .com*/ activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } }
From source file:Main.java
/** * Get a String from the private {@link SharedPreferences} of the app * * @param context The current context of the app * @param key The key we want to request * @return The string retrieved from the given key *//*from w w w .j a v a 2 s. c om*/ public static String getStringForKey(Context context, String key) { if (context == null) { return null; } SharedPreferences sharedPref = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); return sharedPref.getString(key, null); }
From source file:Main.java
public static String getCity(Context context) { SharedPreferences sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); if (sp != null) { return sp.getString(KEY_CITY, "null"); }/*from w ww. j a va 2 s .co m*/ return ""; }
From source file:Main.java
public static String GetString(Context context, String key, String defaultValue) { SharedPreferences settings = context.getSharedPreferences(ConfigurationName, Context.MODE_PRIVATE); return settings.getString(key, defaultValue); }
From source file:Main.java
public static String getBCBUpdatesLastTime(Context context) { SharedPreferences settings = context.getSharedPreferences(BCB_UPDATES_SHARED_PREF, Context.MODE_PRIVATE); return settings.getString(BCB_LAST_UPDATE_TIME, ""); }
From source file:Main.java
public static String getString(Context context, String key, String defaultObject) { if (context == null) return defaultObject; SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getString(key, defaultObject); }
From source file:Main.java
public static String getAllBCBUpdates(Context context, String updates) { SharedPreferences settings = context.getSharedPreferences(BCB_UPDATES_SHARED_PREF, Context.MODE_PRIVATE); return settings.getString(BCB_UPDATES, updates); }
From source file:Main.java
public static String getSalesId(Context context) { SharedPreferences pref = context.getSharedPreferences("sales", Context.MODE_PRIVATE); if (pref != null) { return pref.getString("SalesId", ""); }/* www . ja v a 2s . c o m*/ return null; }
From source file:Main.java
public static String getUserID(Context context) { SharedPreferences settings = context.getSharedPreferences(BCB_UPDATES_SHARED_PREF, Context.MODE_PRIVATE); return settings.getString(BCB_USER_ID, null); }
From source file:Main.java
public static boolean isNewVersion(final Context context) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); final String v0 = p.getString(PREFS_LAST_RUN, ""); String v1 = null;/* ww w .j a v a 2s. co m*/ try { v1 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { Log.e(TAG, "package not found: " + context.getPackageName(), e); } if (v0.equals(v1)) { return false; } return true; }