List of usage examples for android.content SharedPreferences contains
boolean contains(String key);
From source file:com.zia.freshdocs.preference.CMISPreferencesManager.java
@SuppressWarnings("unchecked") protected Map<String, CMISHost> readPreferences(Context ctx) { ConcurrentHashMap<String, CMISHost> prefs = new ConcurrentHashMap<String, CMISHost>(); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(ctx); String encPrefs = null;// w ww .j av a 2 s .c o m if (sharedPrefs.contains(SERVERS_KEY)) { encPrefs = sharedPrefs.getString(SERVERS_KEY, null); if (encPrefs != null) { byte[] repr = Base64.decodeBase64(encPrefs.getBytes()); Object obj = SerializationUtils.deserialize(repr); if (obj != null) { prefs = (ConcurrentHashMap<String, CMISHost>) obj; } } } return prefs; }
From source file:com.jefftharris.passwdsafe.sync.box.BoxProvider.java
@Override public void init() { super.init(); BoxConfig.CLIENT_ID = BOX_CLIENT_ID; BoxConfig.CLIENT_SECRET = BOX_CLIENT_SECRET; BoxConfig.IS_LOG_ENABLED = false;// w w w . jav a 2 s . co m itsClient = new BoxSession(getContext()); itsClient.setSessionAuthListener(this); updateBoxAcct(); // Check for migration SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); if (prefs.contains(PREF_AUTH_REFRESH_TOKEN)) { NotifUtils.showNotif(NotifUtils.Type.BOX_MIGRATGED, getContext()); } if (prefs.contains(PREF_AUTH_USER_ID)) { prefs.edit().remove(PREF_AUTH_USER_ID).apply(); } }
From source file:com.jefftharris.passwdsafe.sync.box.BoxProvider.java
@Override public void startAccountLink(FragmentActivity activity, int requestCode) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); if (prefs.contains(PREF_AUTH_USER_ID) || prefs.contains(PREF_AUTH_REFRESH_TOKEN)) { SharedPreferences.Editor edit = prefs.edit(); edit.remove(PREF_AUTH_USER_ID);//from ww w .j av a 2 s . co m edit.remove(PREF_AUTH_ACCESS_TOKEN); edit.remove(PREF_AUTH_EXPIRES_IN); edit.remove(PREF_AUTH_REFRESH_TOKEN); edit.remove(PREF_AUTH_TOKEN_TYPE); edit.apply(); } if (isAccountAuthorized()) { unlinkAccount(); } Intent intent = new Intent(); itsAcctLinkIntent = activity.createPendingResult(requestCode, intent, PendingIntent.FLAG_ONE_SHOT); itsClient.authenticate(); }
From source file:m2.android.archetype.sharedpref.BaseSharedPrefModel.java
public Object get(String key, Object defaultValue) { if (!getDataMap().containsKey(key)) { SharedPreferences pref = getSharedPreferences(); if (pref.contains(key)) { Map<String, ?> prefData = pref.getAll(); for (Entry<String, ?> entry : prefData.entrySet()) { if (!getDataMap().containsKey(entry.getKey())) { getDataMap().put(entry.getKey(), entry.getValue()); getDirtyMap().put(entry.getKey(), entry.getValue()); }/*from www . jav a2s .c o m*/ } } } if (getDataMap().containsKey(key)) { return getDataMap().get(key); } return defaultValue; }
From source file:com.example.administrator.myapplication2._5_Group._5_Group.LeftFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout._5_community_left, container, false); SharedPreferences myPrefs = this.getActivity().getSharedPreferences("login", Context.MODE_PRIVATE); if ((myPrefs != null) && (myPrefs.contains("id"))) { id = myPrefs.getString("id", ""); Log.i("logintest", id.toString()); }/*from w w w. j a v a 2 s . c om*/ tvGroupName = (TextView) rootView.findViewById(R.id.tvGroupName); tvGroupMember = (TextView) rootView.findViewById(R.id.tvGroupMember); goutBtn = (ImageButton) rootView.findViewById(R.id.goutBtn); goutBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()).setTitle("") .setMessage("? ?").setNegativeButton(android.R.string.no, null) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { outGroup(); } }).create().show(); } }); getGroupName(); return rootView; }
From source file:com.zia.freshdocs.preference.CMISPreferencesManager.java
protected void initDefaultPrefs(Context ctx) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(ctx); // if no user prefs exist, create the default host if (!sharedPrefs.contains(PREFS_SET_KEY)) { CMISHost defaultHost = new CMISHost(); defaultHost.setId(DEFAULT_HOSTNAME); defaultHost.setHostname(DEFAULT_HOSTNAME); defaultHost.setUsername(DEFAULT_USERNAME); defaultHost.setPassword(DEFAULT_PASSWORD); defaultHost.setPort(DEFAULT_PORT); defaultHost.setShowHidden(DEFAULT_SHOWHIDDEN); defaultHost.setSSL(DEFAULT_SSL); defaultHost.setWebappRoot(DEFAULT_WEBAPPROOT); setPreferences(ctx, defaultHost); }/*from w w w. j a v a2 s . com*/ }
From source file:io.github.gsantner.opoc.util.AppSettingsBase.java
public boolean isPrefSet(SharedPreferences pref, @StringRes int stringKeyResourceId) { return pref.contains(rstr(stringKeyResourceId)); }
From source file:org.dpadgett.timer.StopwatchFragment.java
private void restoreState() { final SharedPreferences prefs = context.getSharedPreferences("Stopwatch", Context.MODE_PRIVATE); if (prefs.contains("isTimerRunning")) { isTimerRunning = prefs.getBoolean("isTimerRunning", false); timeStarted = prefs.getLong("timeStarted", 0L); additionalElapsed = prefs.getLong("additionalElapsed", 0L); additionalLapTimeElapsed = prefs.getLong("additionalLapTimeElapsed", 0L); lapTimes.restoreState(prefs);// w ww . j a v a 2 s .com } final Button startButton = (Button) rootView.findViewById(R.id.startButton); final Button resetButton = (Button) rootView.findViewById(R.id.stopButton); timerText.setStartingTime(timeStarted - additionalElapsed - additionalLapTimeElapsed); lapTimeText.setStartingTime(timeStarted - additionalElapsed); if (autoStartStopwatch == true) { if (isTimerRunning) { lap(); } else { // TODO: if current stopped timer == 0, then start // if !=0, then lap and start, that way the time of a stopped timer is not lost. reset(); start(); } autoStartStopwatch = false; } if (isTimerRunning) { timerText.resume(); lapTimeText.resume(); startButton.setText(context.getString(R.string.stopwatch_button_stop)); resetButton.setText(context.getString(R.string.stopwatch_button_lap)); } timerText.forceUpdate(timeStarted); lapTimeText.forceUpdate(timeStarted); }
From source file:com.example.administrator.myapplication2._2_exercise._2_End.RightFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout._2_fragment_map, container, false); Intent myIntent = getActivity().getIntent(); if (myIntent != null) { seq = myIntent.getStringExtra("seq"); }/* w w w . j av a 2 s . co m*/ SharedPreferences myPrefs = this.getActivity().getSharedPreferences("login", Context.MODE_PRIVATE); if ((myPrefs != null) && (myPrefs.contains("id"))) { id = myPrefs.getString("id", ""); } // ? ? map = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map2)).getMap(); map.setMyLocationEnabled(true); arrayPoints = new ArrayList<LatLng>(); // getRecentSeq(); getRecentData(); return rootView; }
From source file:org.amahi.anywhere.service.UploadService.java
private boolean isConnectionAvailable() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); return preferences.contains(getString(R.string.preference_key_server_connection)); }