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 boolean getReasonInDiskFlag(Context context) {
    SharedPreferences pref = context.getSharedPreferences(PREFS_WIBMO_IAP_SDK, Context.MODE_PRIVATE);
    return pref.getBoolean(PREF_HAS_ALARM_IAP_CANCEL_CODES, false);
}

From source file:Main.java

public static void clearSharePrefrences(Context context) {
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.clear();//w  w  w. j  a va2s  .co  m
    editor.commit();
}

From source file:Main.java

public static String getHome(Context context) {

    addressPreferences = context.getSharedPreferences(ADDRESS_PREFERENCE, Context.MODE_APPEND);

    return addressPreferences.getString(HOME_ADDRESS, "");
}

From source file:Main.java

public static void clear(Context context) {
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.clear();//from  w w  w  . ja  v a  2 s.co m
    editor.commit();
}

From source file:Main.java

public static int getCountryFromIdx(Context context) {
    SharedPreferences pref = context.getSharedPreferences(CURRENCY_PREF_NAME, 0);
    return pref.getInt(COUNTRY_FROM_IDX, 0);
}

From source file:Main.java

public static boolean getUseCelsius(Context context) {
    SharedPreferences pref = context.getSharedPreferences(SETTINGS_PREF, Context.MODE_PRIVATE);
    return pref.getBoolean(PREF_USE_CELSIUS, true);
}

From source file:Main.java

public static String getMail(Context c) {
    SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);

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

From source file:Main.java

public static void setChangeMode(Context ctx, int mode) {
    SharedPreferences sp = ctx.getSharedPreferences("config_mode", Context.MODE_PRIVATE);
    sp.edit().putInt(Mode, mode).commit();
}

From source file:Main.java

public static int restoreDistanceTravelled(Context context) {
    SharedPreferences sharedPref = context.getSharedPreferences("Distance", Context.MODE_PRIVATE);
    return sharedPref.getInt("distance", 0);
}

From source file:Main.java

public static String readWLPref(Context paramContext, String paramString) {
    return paramContext.getSharedPreferences("WLPrefs", 0).getString(paramString, null);
}