OnBackPressed() for different activities in same function
<p>I want to navigate on previous activity by using <code>onBackPressed()</code>. I tried the following code :</p>

<pre><code>Intent i=new Intent(detail.this,Data.class);
startActivity(i);
</code></pre>

<p>It's working, navigating on the <code>Data.java</code> file by manually. But my problem is that instead of <code>Data.class</code> there are other activities according to my need, like </p>

<pre><code>Homepage.class==&gt;Data.class====&gt;detail.class
Homepage.class==&gt;Inbox.class====&gt;detail.class
Homepage.class==&gt;Information.class====&gt;detail.class   
</code></pre>

<p>means like this,</p>

<p>For 1st condition</p>

<pre><code>Intent i = new Intent(detail.this, Data.class);
startActivity(i);
</code></pre>

<p>For 2nd condition</p>

<pre><code>Intent i = new Intent(detail.this, Inbox.class);
startActivity(i);
</code></pre>

<p>For 3rd condition</p>

<pre><code>Intent i = new Intent(detail.this, Information.class);
startActivity(i);
</code></pre>

<p>Now my question is: how to know the previous activity class name and how to replace the class name data.class in following line automatically </p>

<pre><code>Intent i = new Intent(detail.this, Data.class); 
</code></pre>