There is a recyclerView list in which I initialize the names:

private void initName() { categories = new ArrayList<>(); categories.add(new Category(getString(R.string.one))); categories.add(new Category(getString(R.string.two))); categories.add(new Category(getString(R.string.three))); categories.add(new Category(getString(R.string.four))); categories.add(new Category(getString(R.string.five))); categories.add(new Category(getString(R.string.six))); } 

Where further for each name I make the transition, approximately as follows:

  private void initializeAdapter() { Adapter adapter = new Adapter(categories, position -> { Intent intent; switch (position) { case 0: intent = new Intent(getActivity(), One.class); break; 

The task is to transfer / click on the names with the SharedPreference into some kind of activity (something like the favorites).

  • one
    It is not clear what exactly the problem? How to determine which item was clicked? How to write to SharedPrefreences? How to transfer in the launched Activity parameter? How to get it out of the intent? How to store a list in SharedPreferences? :) - tse
  • Well, it turns out that yes the click happens, which element is also understandable, well, at least to me, since it goes into another activity with his name. But how to define this click in sharedPreference? After initialization, so I understand, you need to write something like that 'Editor e = sp.edit (); e.putStringSet ("strSetKey", categories); e.apply (); 'And after that, like reading the info that was clicked on it. - Inkognito

0