How to Transfer Data between Android Activity using KotlinVivek Kumar kanaujia
Here is i am describing how to transfer variable or value from one Activity to Another Activity in Android Application.I am using Android Studio 3.0.I hope my code will help you. You can use this code in button event or any other place where it is required.
Set Data in Activity
val myvalue="I am from Main Activity" val myActivity = Intent(applicationContext, Another_activity::class.java) //name of activity to launch myActivity.putExtra("value",myvalue) // value will save of your myvalue variable used for another activity startActivity(myActivity) //to launch another activity
Get Data from Activity
//create this code in Another_activity.kt //getting/fetch Intent value val data = intent.extras.getString("value") //Now its your choice whatever you want to do with data.
feel free to comment and feedback