I have three activities, from A it is going to B, from B it is going to C. I am using following code to transfer from one activity to another.

```
Intent intent = new Intent().setClass(this, B.class);
startActivity(intent);

```

I want that when I use the back button, it should come to B if it is at C(which is ok for me), but if I use back button at B activity, it should not go to A, it should directly go out the application. How it can be arranged?