Example usage for android.content Context getSharedPreferences

List of usage examples for android.content Context getSharedPreferences

Introduction

In this page you can find the example usage for android.content Context getSharedPreferences.

Prototype

public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);

Source Link

Document

Retrieve and hold the contents of the preferences file, returning a SharedPreferences through which you can retrieve and modify its values.

Usage

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 void setReasonInDiskFlag(Context context, boolean flag) {
    SharedPreferences pref = context.getSharedPreferences(PREFS_WIBMO_IAP_SDK, Context.MODE_PRIVATE);
    SharedPreferences.Editor syncContactsEditor = pref.edit();
    syncContactsEditor.putBoolean(PREF_HAS_ALARM_IAP_CANCEL_CODES, flag);
    syncContactsEditor.commit();//from w  w  w .j  av a 2  s.c o  m
}

From source file:Main.java

public static void setIsInitialised(boolean value, Context context) {
    SharedPreferences.Editor prefsEditor = context.getSharedPreferences(PREFS, MODE).edit();
    prefsEditor.putBoolean(PREF_INITIALISED, false);
    prefsEditor.commit();//from  ww w . jav  a2s  .c  o m
}

From source file:Main.java

public static boolean checkLogin(Context context) {
    SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config",
            Context.MODE_PRIVATE);
    String string = userPreferences.getString("jdycode", "");
    if (string.length() > 10) {
        return true;
    }/* w ww.  ja v  a 2  s  .  c  om*/
    return false;
}

From source file:Main.java

public static boolean hasAsymmericMasterSecret(Context context) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCES_NAME, 0);
    return settings.contains(ASYMMETRIC_LOCAL_PUBLIC);
}

From source file:Main.java

public static boolean getScheduleUpdated(Context context) {
    SharedPreferences settings = context.getSharedPreferences(BCB_UPDATES_SHARED_PREF, Context.MODE_PRIVATE);
    return settings.getBoolean(BCB_UPDATE_AVAILABLE, false);
}

From source file:Main.java

public static void putIpPort(Context context, String ip) {
    SharedPreferences preferences = context.getSharedPreferences(IP_PORT, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, ip).commit();
}

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 String getString(Context ctx, String key, String defValue) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    return sp.getString(key, defValue);
}

From source file:Main.java

public static String getString(Context context, String key) {
    SharedPreferences preferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);

    return preferences.getString(key, "");
}