List of usage examples for android.content Context getSharedPreferences
public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);
From source file:Main.java
public static boolean isWelcomeShown(final Context ctx) { return ctx.getSharedPreferences("_welcome_dialog_shown", Context.MODE_PRIVATE).getBoolean("shown", false); // LayoutInflater inflatter = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // AlertDialog.Builder builder = new AlertDialog.Builder(ctx); // View view = inflatter.inflate(R.layout.welcomedialog, null); // builder.setView(view); // final AlertDialog dialog = builder.create(); // CheckBox cb = (CheckBox) view.findViewById(R.id.welcomeCheckbox); // cb.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // ctx.getSharedPreferences("_welcome_dialog_shown", Context.MODE_PRIVATE).edit().putBoolean("shown", true).commit(); // dialog.dismiss(); // }// www. j av a2 s . c o m // }); // dialog.show(); }
From source file:Main.java
public static int getInt(Context ctx, String key, int defaultValue) { SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); return sp.getInt(key, defaultValue); }
From source file:Main.java
public static String getDefaultRenderName(Context context) { String s;//from ww w.j a va 2s.c o m try { s = context.getSharedPreferences(context.getPackageName(), 1).getString("default_render_name", null); } catch (Exception exception) { exception.printStackTrace(); return null; } return s; }
From source file:Main.java
public static boolean save(Context context, String key, String value) { SharedPreferences sp = context.getSharedPreferences("app", 0); return sp.edit().putString(key, value).commit(); }
From source file:Main.java
public static String getDefaultRenderUDN(Context context) { String s;// w ww .j ava2 s . co m try { s = context.getSharedPreferences(context.getPackageName(), 1).getString("default_render_udn", null); } catch (Exception exception) { exception.printStackTrace(); return null; } return s; }
From source file:Main.java
public static void putBoolean(Context context, String key, boolean value) { SharedPreferences sp = context.getSharedPreferences("fq", Context.MODE_PRIVATE); sp.edit().putBoolean(key, value).commit(); }
From source file:Main.java
/** This function save last Push Notification message in prferences * @param projectNo/* w ww . j a v a 2s .com*/ */ public static void saveLastMessage(String message, Context context) { SharedPreferences sharedPreference = context.getSharedPreferences(AppName, PrivateMode); SharedPreferences.Editor prefEditor = sharedPreference.edit(); prefEditor.putString(KeyLastMessage, message); prefEditor.commit(); }
From source file:Main.java
public static void putBoolean(Context mContext, String key, boolean value) { SharedPreferences sp = mContext.getSharedPreferences("atguigu", Context.MODE_PRIVATE); sp.edit().putBoolean(key, value).commit(); }
From source file:Main.java
public static void putString(Context context, String key, String value) { SharedPreferences sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); sp.edit().putString(key, value).commit(); }
From source file:Main.java
public static String getGcmId(Context context) { final SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE); return prefs.getString(PROPERTY_REG_ID, null); }