title: How do I save the value from my second activity to my first activity android studio
body: <p>For my main activity, it displays a text and a button. The text originally displays the word &quot;cat&quot;. When the button is pressed, it brings it over to the 2nd activity where the user can edit the text. When the back button is pressed, the text will change to what the user edited.
  My problem is, the original value does not change or save to the new edited version. So when I press the button again, the 2nd activity will display the original value &quot;Cat&quot;, when it should display what the user edited earlier.</p>
  <p>Where did i go wrong here?</p>
  <pre><code>class MainActivity : AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          val name = &quot;Cat&quot;
          val textview = findViewById&lt;TextView&gt;(R.id.textView)
          textview.text = name
  
          val button = findViewById&lt;Button&gt;(R.id.button)
  
          button.setOnClickListener {
              val i = Intent(this, MainActivity2::class.java).apply {
                  putExtra(&quot;name&quot;, Info(name))
              }
              startActivityForResult(i, 0)
          }
      }
  
      override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
          super.onActivityResult(requestCode, resultCode, data)
          if(requestCode == 0) {
              textView.text = data?.getStringExtra(&quot;message&quot;)
              val name = textView
          }
      }
  }
  </code></pre>
  <p>My Second Activity</p>
  <pre><code>class MainActivity2 : AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main2)
  
          val info = intent.getParcelableExtra&lt;Info&gt;(&quot;name&quot;)
          val result = findViewById&lt;EditText&gt;(R.id.editText)
          result.setText(info?.name)
      }
  
      override fun onBackPressed() {
  
          val i = Intent().apply{
              putExtra(&quot;message&quot;, editText.text.toString())
          }
  
          setResult(Activity.RESULT_OK, i)
          super.onBackPressed()
      }
  }
  </code></pre>
  <p>Parcable class</p>
  <pre><code>@Parcelize
  data class Info ( val name : String) : Parcelable {
  }
  </code></pre>