title: Android Studio: Back Button for previous Activity
body: <p>I've created an <code>Activity</code> with a <code>Navigation Drawer</code> and replaced the options icon (placed in the top-right corner) with an <code>ImageButton</code> to handle the back click. </p>
  
  <p>The problem is, that I don't know how to do it. I'm a little confused about how to use the back button. What code should I do to go to the previous <code>Activity</code>?</p>
  
  <p>A back button for:
  Activity to Another Activity and MainActivity to Fragment activity.</p>
  
  <p>this is my <strong>Manifest code:</strong></p>
  
  <pre><code>   &lt;activity
          android:name="com.teamamazing.with_sidebar.activity.Accomodation"
          android:label="Accomodation"
          android:parentActivityName="com.teamamazing.with_sidebar.activity.SpecialPage"&gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="com.teamamazing.with_sidebar.activity.SpecialPage" /&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>this is my <strong>Accommodation activity:</strong></p>
  
  <pre><code>package com.teamamazing.with_sidebar.activity;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import com.teamamazing.with_sidebar.R;
  
  
  public class Accomodation extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_accomodation);
    } }
  </code></pre>
  
  <p>and this is my <strong>SpecialPage code:</strong> which will be the parent activity.</p>
  
  <pre><code>package com.teamamazing.with_sidebar.activity;
  
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ImageButton;
  import com.teamamazing.with_sidebar.R;
  
  
  public class SpecialPage extends AppCompatActivity {
  
  public ImageButton accomodation;
  
  
  public void init() {
      accomodation = (ImageButton) findViewById(R.id.AccomodationButton);
      accomodation.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View v) {
  
              Intent accomodation = new Intent(SpecialPage.this, Accomodation.class);
  
              startActivity(accomodation);
  
  
          }
      });
  }
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_special_page);
  
      init();
  }}
  </code></pre>
  
  <p>Thank you for the answer.</p>