title: Go back to specific activity from stack
body: <p>I'm trying to do something like file manager. And in action bar I wanna to do folder navigation like in &quot;google drive&quot; app. I need create method which can go to previous activity by number from end, or something like this.</p>
  <p>Example:</p>
  <blockquote>
  <p>So if I have stack: [1] -&gt; [2] -&gt; [3] -&gt; [4] -&gt; [5]</p>
  <p>And I need go to second: so I need delete [3], [4], and [5] from stack and go to [2].</p>
  <p>All activities is one class ContentActivity.java.</p>
  </blockquote>
  <p>How it possible to do?</p>
  <p>UPDATE:</p>
  <p>Some code how I start activities:</p>
  <pre><code>public class ContentActivity extends Activity implements AdapterView.OnItemClickListener {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_list);
  
          Intent intent = getIntent();
          String folderToOpen = intent.getStringExtra(&quot;folderName&quot;);
          fillList(folderToOpen);
      }
  
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
          ...
          Intent intent = new Intent(ContentList.this, ContentList.class);
          intent.putExtra(&quot;folderName&quot;, item.getName());
          startActivity(intent);
      }
  }
  </code></pre>