There is a method where I save the values of the clicked item in my recyclerView:
private void saveFavorites(int position) { String name = personCategories.get(position); SharedPreferences sp = getActivity().getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putString(Constants.KEY_SP, name); editor.apply(); } Then I receive the data in another fragment as follows:
private String getFavorites() { SharedPreferences sp = getActivity().getPreferences(Context.MODE_PRIVATE); return sp.getString(Constants.KEY_SP, null); } The hitch is that I only get one item that I clicked last on the list. How to make it appear as an array? And all the elements that I clicked were added to the second fragment?