I have one recyclerview so the task is to get the data from another activity and set it to the main activity's recyclerview and when we press on particular row of list so, it get back to the editable mode and edittext fill with old data and replace it with new data and again show update data in recyclerview.
-
Can you go in detail ?' – Rishabh Saxena Sep 10 '18 at 04:58
-
Why you don't want to use PutExtra()? – Gokul Nath KP Sep 10 '18 at 05:05
-
there can be more then 10 ways to send data (good and bad ways) to achieve this..it depends on your capability like using static variables,using interface..using shared preferences...be more specific and clear – Ashwini Saini Sep 10 '18 at 05:06
-
1You can do it by using startActivityForResult() – Tayyab Amin Sep 10 '18 at 05:11
3 Answers
Yes, you can do this by using the startActivityForResult()
from list item adapter and at that time you can pass the data through it.
Follow the steps:
1. Implement Main Activities recyclerview
2. Get the data from another activity and show into Main Activities recyclerview.
3. Now, On List item click start the previous activity with startActivityForResult()
and pass the full list or the specific list item object as per your list complexity.
4. On The Launched screen get the data from intent and show the filled data to the user.
5. As soon as user makes any change to the data and clicks on submit then finish the activity and you should handle the onActivityResult
on the previous screen to update the recycler's view data.
Also, you can store the data in Shared Preferences and while launching the new screen you can get the same data from shared preferences.

- 251
- 2
- 5
There are three major way to communicate component of android we can say pass data, which is bellow
- Using BroadcastReceiver: using broadcast receiver you can transfer data between tow activity or activity or service, bellow is the link which will help you
https://developer.android.com/guide/components/broadcasts Using static variable: You can declare the static variable and set value when you want to use, Like if I am declaring static variable A in Activity1 so I can change or access value of variable A from any of activity using Activity1.A.
Using Intent when starting activity: when we starting activity we can send data using intent put extra.

- 4,589
- 1
- 23
- 39