Code example for SharedPreferences

Methods: edit

0
	} 
 
	@Override 
	public void writeToSharedPreferences(SharedPreferences sharedPrefs)
	{ 
		super.writeToSharedPreferences(sharedPrefs);
		 
		SharedPreferences.Editor editor = sharedPrefs.edit();
		editor.putString("bookmark.hostname", hostname);
		editor.putInt("bookmark.port", port);
		editor.commit();		
	} 
 
	@Override 
	public void readFromSharedPreferences(SharedPreferences sharedPrefs)
	{ 
		super.readFromSharedPreferences(sharedPrefs);
		 
		hostname = sharedPrefs.getString("bookmark.hostname", "");
		port = sharedPrefs.getInt("bookmark.port", 3389);
	}