Techiio-author
Started by Debarghya DasSep 14, 2021

Open
How to edit the data received from the intent.putExtra?

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

I am sending a list data from Activity "A" to Activity "B" using intent as follows.

private var items : Lists<Items> 

context.startActivity(
Intent(context, B::class.java).apply {
putExtra("itemList", items as ArrayList)
}
)

Inside Activity "B"

   val itemList = intent?.extras?.getSerializable("itemList") as? ArrayList<Tweet>

// trying to edit the list
items.forEachIndexed { index, t ->
run {
if (t.id == tweet.id) {
items[index].name = "hello"
}
}
}

However, when I try to edit the list items, it is not editing the list. Is it because when I send the data using intent is it sending a copy of my original data? Any help would be appreciated.

0 Replies

You must be Logged in to reply
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance