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 void saveDate(Context context) {
    SharedPreferences sp = context.getSharedPreferences("upushlog_time", Context.MODE_PRIVATE);
    if (0 == sp.getLong("time", 0)) {
        sp.edit().putLong("time", System.currentTimeMillis()).commit();

    }//from ww w .ja  v a2  s.  co  m

}

From source file:Main.java

public static int getIntDataToSp(Context context, String key, int defaultVlue) {
    return context.getSharedPreferences("hask", 0).getInt(key, defaultVlue);
}

From source file:Main.java

public static Boolean IsFirstLogin(Context context) {
    SharedPreferences preferences = context.getSharedPreferences("FirstLogin", Context.MODE_PRIVATE);
    return preferences.getBoolean("Isfirst", false);
}

From source file:Main.java

public static boolean isMapHintVisible(Context context) {
    SharedPreferences sharedPref = context.getSharedPreferences(KEY_SHOW_MAP_HINT, Context.MODE_PRIVATE);
    return sharedPref.getBoolean(KEY_SHOW_MAP_HINT, true);
}

From source file:Main.java

public static long getCacheTime(Context context) {
    SharedPreferences settings = context.getSharedPreferences("Preference", 0);
    long cacheTime = settings.getLong("CacheTime", 0);
    return cacheTime;
}

From source file:Main.java

public static void load(Context ctx) {
    sConfig = ctx.getSharedPreferences(CFG_FILE, Context.MODE_PRIVATE);
    if (sConfig.getString(CFG_HOST, null) == null) {
        edit(CFG_HOST, DEF_HOST);//from   w  w  w .jav a  2 s.  c  o m
    }
    if (sConfig.getString(CFG_SOCKET_PORT, null) == null) {
        edit(CFG_SOCKET_PORT, DEF_SOCKET_PORT);
    }
    sIsLoaded = true;
}

From source file:Main.java

static String loadCurrentAppKey(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(AGE_PREFERENCES, Context.MODE_PRIVATE);

    return prefs.getString(AGE_CURRENT_APP_KEY, null);
}

From source file:Main.java

private static SharedPreferences getDefaultPreferences(Context context) {
    return context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
}

From source file:Main.java

public static float getProtGoal(Context c) {
    sharedpreferences = c.getSharedPreferences(SHARED_PREF_FILE_NAME, 0);
    float result = sharedpreferences.getFloat(PROT_GOAL_PREF_NAME, 9999);//9999(magic number) is error number meaning no goal has been set yet ie: promt the wizard
    return result;
}

From source file:Main.java

public static synchronized String getUserName(final Context context) {
    SharedPreferences pref = context.getSharedPreferences(KEY_STORAGE, Context.MODE_PRIVATE);
    return pref.getString(AUTH_NAME, null);
}