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 putQQid(Context context, String qqid) {
    SharedPreferences preferences = context.getSharedPreferences(QQ, Context.MODE_PRIVATE);
    preferences.edit().putString(QQ_ID, qqid).commit();
}

From source file:Main.java

public static void writeCameraId(Context context, String value) {
    SharedPreferences preferences = context.getSharedPreferences("CameraConfig", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString("camera", value);
    editor.commit();//w  ww . java 2 s. co  m
}

From source file:Main.java

public static void putLAT(Context context, String city) {
    SharedPreferences preferences = context.getSharedPreferences(LAT, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, city).commit();
}

From source file:Main.java

public static void save_screen_status(Context context) {
    SharedPreferences localSharedPreferences = context.getSharedPreferences("SCREEN_STATUS", 0);
    Editor localEditor = localSharedPreferences.edit();
    localEditor.putInt("screen_count", localSharedPreferences.getInt("screen_count", 0) + 1);
    localEditor.commit();/*  w w  w  .  j  a v  a  2 s  . co m*/
}

From source file:Main.java

public static void putBoolean(Context context, String key, boolean value) {
    SharedPreferences sp = context.getSharedPreferences("budejie", Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, value).commit();
}

From source file:Main.java

public static String getString(Context context, String key) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("fucang", Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, "");
}

From source file:Main.java

public static void savePreference(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    sp.edit().putString(key, value).apply();
}

From source file:Main.java

public static void putBoolean(Context context, String key, boolean values) {
    SharedPreferences sp = context.getSharedPreferences("xiaolu", Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, values).commit();
}

From source file:Main.java

public static String getString(Context context, String key) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("atguigu", Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, "");
}

From source file:Main.java

public static void saveStringSp(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, context.MODE_PRIVATE);
    sp.edit().putString(key, value).commit();
}