Application based on Android ItemTouchHelper-Demo .

There is an ArrayList with images.

It is possible to move images.

After exiting the application, the elements of the list take the original position.

How to remember the position of an element after moving and exiting the application?

    1 answer 1

    The adapter has a List<String> mItems in which data is stored that is displayed in RecyclerView . When you change the order of items in RecyclerView , the order of items in mItems changes as mItems .

    To preserve the order of elements, you need to somehow save the mItems list when you exit the application and load the saved list into mItems when the application starts.

    The mItems list can be saved, for example, just to a file. You can also use other approaches to save this data, but to a greater extent it depends on the architecture of your application.