title: i want to chenge the button text after adding the data to RoomDatabase
body: <p>i am creating a button in details activity that displays the data of Sandwitches.</p>
  <p>i want to add sandwitches to room database with button.
  This is my code.</p>
  <pre><code>import android.app.Application;
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  import com.squareup.picasso.Picasso;
  import android.arch.lifecycle.ViewModelProviders;
  
  public class DetailsActivy extends AppCompatActivity {
      SandwitchViewModel sandwitchViewModel ;
      SharedPreferences sharedPreferences;
      SharedPreferences.Editor myEdit;
      SandwitchDetails sandwitch;
      TextView name,alsoknownas,ingridients,placeoforigin,description;
      Button makingvideo,likeButton;
      ImageView URL;
      String sandwitchname;
      String originofSandwitch;
      String imageURL;
      String sandwitchdesc;
      String sandwitchalsoknown=&quot;&quot;;
      String sandwitchingreds=&quot;&quot;;
      String makinglink;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_details_activy);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          getSupportActionBar();
          sharedPreferences = getSharedPreferences(&quot;ButtonText&quot;,MODE_PRIVATE);
          myEdit = sharedPreferences.edit();
          Bundle data = getIntent().getExtras();
          sandwitch = (SandwitchDetails) data.getSerializable(getString(R.string.details_sandwitchobject));
          sandwitchViewModel =  ViewModelProviders.of(this).get(SandwitchViewModel.class);
          sandwitchname = sandwitch.getName();
          originofSandwitch = sandwitch.getPlaceoforigin();
          imageURL = sandwitch.getURL();
          sandwitchdesc = sandwitch.getDescription();
          makinglink = sandwitch.getYoutubelink();
          name = (TextView) findViewById(R.id.name);
          alsoknownas = (TextView) findViewById(R.id.sandalsoknownas);
          placeoforigin = (TextView) findViewById(R.id.originplace);
          description = (TextView) findViewById(R.id.sanddescription);
          URL = (ImageView) findViewById(R.id.sandwitchimage);
          ingridients = (TextView) findViewById(R.id.sandingredients);
          makingvideo = (Button) findViewById(R.id.makingvideo);
          likeButton = (Button) findViewById(R.id.databaseadd);
          loadUI();
      }
  
  
      void loadUI(){
          Picasso.with(this).load(imageURL).into(URL);
          name.setText(sandwitchname);
          placeoforigin.setText(originofSandwitch);
          description.setText(sandwitchdesc);
          for(int j=0;j&lt;sandwitch.getAlsoknownas().size();j++)
          {
              sandwitchalsoknown = sandwitchalsoknown + (String) sandwitch.getAlsoknownas().get(j) + &quot;\n&quot;;
          }
          for(int j=0;j&lt;sandwitch.getIngridients().size();j++)
          {
              sandwitchingreds = sandwitchingreds + (String)sandwitch.getIngridients().get(j)+&quot;\n&quot;;
          }
          alsoknownas.setText(sandwitchalsoknown);
          ingridients.setText(sandwitchingreds);
          
      }
  
  
  
      public void playVideo(View view) {
          Bundle bundle = new Bundle();
          bundle.putString(getString(R.string.video_url),makinglink);
          Fragment fragment = new YoutubeVideo();
          fragment.setArguments(bundle);
          FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
          fragmentTransaction.replace(R.id.videofragment, fragment);
          fragmentTransaction.addToBackStack(null);
          fragmentTransaction.commit();
      }
  
      public void addAndDeleteToDatabase(View view)
      {
          String buttontext = (String) likeButton.getText();
          SandwitchEntity sandwitchEntity;
          if(buttontext.equals(&quot;like&quot;))
          {
  
              sandwitchEntity = new SandwitchEntity(sandwitchname,sandwitch.getAlsoknownas(),sandwitch.getIngridients(),originofSandwitch,sandwitchdesc,imageURL,makinglink);
              SandwitchEntity r =  sandwitchViewModel.checkSandwichInDatabase(sandwitchEntity.getName());
              if(r==null)
              {
                  sandwitchViewModel.insert(sandwitchEntity);
                  likeButton.setText(&quot;Dislike&quot;);
                  Toast.makeText(this, &quot;Inserted&quot;, Toast.LENGTH_SHORT).show();
                  myEdit.putString(&quot;name&quot;, likeButton.getText().toString());
                  myEdit.commit();
              }
              else
              {
                  Toast.makeText(this, &quot;Liked Previously&quot;, Toast.LENGTH_SHORT).show();
              }
          }
          else{
              sandwitchEntity = new SandwitchEntity(sandwitchname,sandwitch.getAlsoknownas(),sandwitch.getIngridients(),originofSandwitch,sandwitchdesc,imageURL,makinglink);
              SandwitchEntity r =  sandwitchViewModel.checkSandwichInDatabase(sandwitchEntity.getName());
              if(r!=null)
              {
                  sandwitchViewModel.delete(sandwitchEntity);
                  likeButton.setText(&quot;like&quot;);
                  Toast.makeText(this, &quot;Deleted&quot;, Toast.LENGTH_SHORT).show();
                  myEdit.putString(&quot;name&quot;, likeButton.getText().toString());
                  myEdit.commit();
              }
              else
              {
                  Toast.makeText(this, &quot;Not Liked Previously&quot;, Toast.LENGTH_SHORT).show();
              }
          }
      }
  }
  </code></pre>
  <p>i want the button text to be &quot;Dislike&quot; after adding in the database.But after coming out of this activity it is becoming &quot;Like&quot; because of oncreate method.
  can i be able to do this?</p>