SharedPreferences getAll - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SharedPreferences getAll method.

This code example shows how to use the following methods:getAll
		return sharedPrefs.getString(key, defValue);
	} 
 
	@Override 
	public Map<String, ?> get () {
		return sharedPrefs.getAll();
	} 
 
	@Override 
	public boolean contains (String key) {
		return sharedPrefs.contains(key);
	} 
 
	@Override 
	public void clear () { 
		edit(); 
		editor.clear();
	} 
 
	@Override 
7
CodeRank
This code example shows how to use the following methods:getAll, getStringSet
  @TargetApi(11) 
  @Override 
  public void onSharedPreferenceChanged(SharedPreferences prefs,
                                        String key) {
    Intent i=new Intent(ACTION_SYNC_PREF);
    Object value=prefs.getAll().get(key);
 
    i.putExtra(EXTRA_SENDER, getPackageName());
    i.putExtra(EXTRA_KEY, key);
 
    if (value instanceof Boolean) {
      i.putExtra(EXTRA_VALUE, (Boolean)value);
      i.putExtra(EXTRA_TYPE, TYPE_BOOLEAN);
    } 
    else if (value instanceof Float) {
      i.putExtra(EXTRA_VALUE, (Float)value);
      i.putExtra(EXTRA_TYPE, TYPE_FLOAT);
    } 
    else if (value instanceof Integer) {
      i.putExtra(EXTRA_VALUE, (Integer)value);

6
CodeRank
This code example shows how to use the following methods:getAll
     * @param keyResource 
     * @param value 
     */ 
    public static void setIfUnset(SharedPreferences prefs, Editor editor, Resources r, int keyResource, boolean value) {
        String key = r.getString(keyResource);
        if(!prefs.contains(key) || !(prefs.getAll().get(key) instanceof Boolean))
            editor.putBoolean(key, value);
    } 
 
    /** 
     * Helper to write to editor if key specified is null 
     * @param prefs 
     * @param editor 
     * @param r 
     * @param keyResource 
     * @param value 
     */ 
    public static void setIfUnset(SharedPreferences prefs, Editor editor, Resources r, int keyResource, String value) {
        String key = r.getString(keyResource);
        if(!prefs.contains(key) || !(prefs.getAll().get(key) instanceof String))
6
CodeRank
This code example shows how to use the following methods:getAll
    SharedPreferences localPrefs=null;
 
    @Override 
    protected Void doInBackground(Context... ctxt) {
      localPrefs=PreferenceManager.getDefaultSharedPreferences(ctxt[0]);
      localPrefs.getAll();
 
      return(null); 
    } 
 
    @Override 
    public void onPostExecute(Void arg0) {
      ModelFragment.this.prefs=localPrefs;
      ModelFragment.this.prefsTask=null;
      deliverModel(); 
    } 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:getAll
 
    @Override 
    public void onLoad() { 
    	super.onLoad(); 
    	mModule = this.bindExtensionModule(KirinPreferences.class);
        mModule.mergeOrOverwrite(new JSONObject(mPreferences.getAll()));
 
         
         
    	mKirinHelper.jsMethod("mergeOrOverwrite", mPreferences.getAll());
        mKirinHelper.jsMethod("resetEnvironment"); 
    } 
     
    @Override 
    public void onUnload() { 
    	super.onUnload(); 
    } 
     
    /* (non-Javadoc) 
     * @see com.futureplatforms.android.jscore.services.ISettingsBackend#updateContents_withDeletes_(org.json.JSONObject, org.json.JSONArray) 
6
CodeRank
This code example shows how to use the following methods:getAll
    } 
 
    @Override 
    public void onLoad() { 
    	super.onLoad(); 
        mKirinHelper.jsMethod("mergeOrOverwrite", mPreferences.getAll());
        mKirinHelper.jsMethod("resetEnvironment"); 
    } 
     
    /* (non-Javadoc) 
     * @see com.futureplatforms.android.jscore.services.ISettingsBackend#updateContents_withDeletes_(org.json.JSONObject, org.json.JSONArray) 
     */ 
    public void updateContents_withDeletes_(JSONObject contents, JSONArray deletes) {
        try { 
            Editor editor = mPreferences.edit();
 
            for (int i = 0; i < deletes.length(); i++) {
                String key = deletes.getString(i);
                editor.remove(key);
            } 
6
CodeRank
This code example shows how to use the following methods:edit, getAll
  /** 
   * Write a complete set of unversioned global prefs suitable for testing forward migration. 
   * @throws Exception 
   */ 
  public void populateGlobalSharedPrefs(final SharedPreferences to) throws Exception {
    final Editor editor = to.edit();
 
    editor.putLong("earliestnextsync", 1340402318649L);
    editor.putBoolean("clusterurlisstale", false);
 
    editor.commit();
  } 
 
  /** 
   * Write a complete set of unversioned Account data suitable for testing forward migration. 
   * @throws Exception 
   */ 
  public void populateAccountData(final AccountManager accountManager, final Account account) throws Exception {
    accountManager.setUserData(account, "account.guid", TEST_GUID);
    accountManager.setUserData(account, "account.clientName", TEST_CLIENT_NAME);

6
CodeRank
This code example shows how to use the following methods:getAll
	public void addPreferenceListener(final KirinPreferenceListener listener) {
		mPreferences.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
			 
			@Override 
			public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
				listener.onPreferenceChange(key, sharedPreferences.getAll().get(key));
			} 
		});		 
	} 
 
	@Override 
	public void removePreferenceListener() { 
		// TODO Auto-generated method stub 
		 
	} 
 
		@Override 
		public void addInterestFor(String preferenceName) {
			// TODO Auto-generated method stub 
			 
6
CodeRank
This code example shows how to use the following methods:getAll, getInt
	 */ 
	public String getString(String key, String def)
	{ 
		LogHelpers.DebugLog("getString called with key:" + key + ", def:" + def);
 
		Object value = preferences.getAll().get(key);
		if (value != null) {
			return value.toString();
		} else { 
			return def;
		} 
	} 
 
	public SharedPreferences getPreference()
	{ 
		return preferences;
	} 
	 
	/** 
	 * Maps the specified key with a String value. If value is null, existing key will be removed from preferences. 

5
CodeRank
This code example shows how to use the following methods:getAll
	 * 获取所有键值对。 
	 *  
	 * @return 获取到的所胡键值对。 
	 */ 
	public Map<String, ?> getAll() {
		return mKV.getAll();
	} 
 
	/** 
	 * 设置一个键值对,它将在{@linkplain #commit()}被调用时保存。<br/> 
	 * 注意:当保存的value不是boolean, byte(会被转换成int保存),int, long, float, 
	 * String等类型时将调用它的toString()方法进行值的保存。 
	 *  
	 * @param key 
	 *            键名称。 
	 * @param value 
	 *            值。 
	 * @return 引用的KV对象。 
	 */ 
	public KV put(String key, Object value) {
5
CodeRank

Related SharedPreferences getAll Questions & Answers:

getAll Method Overview
Retrieve all values from the preferences.
See Code Examples for other Android SharedPreferences Methods: