Android SharedPreferences.Editor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SharedPreferences.Editor class.

This code example shows how to use the following methods:commit, remove
	 * Utility methods go here 
	 */ 
 
	public void clearState() { 
		Editor editor = m_prefs.edit();
		editor.remove(PREF_FIRSTRUN);
		editor.remove(PREF_DONE_REV);
		editor.remove(PREF_TODO_REV);
		editor.remove(PREF_NEED_TO_PUSH);
		editor.commit();
	} 
 
	public void clear() { 
		Editor editor = m_prefs.edit();
		editor.clear();
		editor.commit();
	} 
 
	public void registerOnSharedPreferenceChangeListener( 
			SharedPreferences.OnSharedPreferenceChangeListener listener) {
10
CodeRank
This code example shows how to use the following methods:commit, putInt
 
	protected void onListItemClick (ListView listView, View view, int position, long id) {
		super.onListItemClick(listView, view, position, id);
 
		Editor editor = prefs.edit();
		editor.putInt("index", listView.getFirstVisiblePosition());
		editor.putInt("top", listView.getChildAt(0) == null ? 0 : listView.getChildAt(0).getTop());
		editor.commit();
 
		Object o = this.getListAdapter().getItem(position);
		String testName = o.toString();
 
		Bundle bundle = new Bundle();
		bundle.putString("test", testName);
		Intent intent = new Intent(this, GdxTestActivity.class);
		intent.putExtras(bundle);
 
		startActivity(intent);
	} 
 
8
CodeRank
This code example shows how to use the following methods:commit, putLong, putString
This code example shows how to use the following methods:commit, putString
This code example shows how to use the following methods:commit, putBoolean
This code example shows how to use the following methods:commit, putInt, putLong, putString
This code example shows how to use the following methods:commit, putString
This code example shows how to use the following methods:commit, putLong, putString
This code example shows how to use the following methods:commit, putLong, putString
	 * @param token Oauth2AccessToken 
	 */ 
	public static void keepAccessToken(Context context, Oauth2AccessToken token) {
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
		Editor editor = pref.edit();
		editor.putString("token", token.getToken());
		editor.putLong("expiresTime", token.getExpiresTime());
		editor.commit();
	} 
	/** 
	 * 清空sharepreference 
	 * @param context 
	 */ 
	public static void clear(Context context){
	    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
	    Editor editor = pref.edit();
	    editor.clear();
	    editor.commit();
	} 
 
7
CodeRank
This code example shows how to use the following methods:commit, putString

Related Android SharedPreferences.Editor Questions & Answers:

Other Android SharedPreferences.Editor Examples

12:		
13:		// Editor for Shared preferences
14:		Editor editor;
15:		
16:		// Context

Read More

25:								// Edit Preferences and update facebook acess_token
26:								SharedPreferences.Editor editor = mPrefs.edit();
27:								editor.putString("access_token",
28:										facebook.getAccessToken());
29:								editor.putLong("access_expires",

Read More

12:		
13:		// Editor for Shared preferences
14:		Editor editor;
15:		
16:		// Context

Read More

See Code Examples for Android SharedPreferences.Editor Methods: