'send id number from recyclerview to another activity

I have an activity that contains a RecyclerView and a button that open another activity with some EditTexts that insert the data to google sheet and I read all the data of it in the RecyclerView, I use one of these EditTexts to insert a number(id) for each item of the Google sheet, what I want is to make this process automatically, and I don't want it to be getPosition()+1 because sometimes I delete some data from it so the ID's gets changes if there is any other way for it please help me thank you very much.



Solution 1:[1]

  1. In RecyclerView, pass desired data to parent activity in callback (such as listener) method.

  2. Pass data from an existing activity to another activity through intent.

  3. Other activity receives data through getIntent.

There are other ways such as DataStore, Argument(Fragment), ActivityViewModel, and Bundle, but this is probably the easiest.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PJH