I'm trying to use an int to open up different graphs. I want this int to change values when a button is pressed, but it isn't changing. Here's my code:
public class PatientDemographics extends Activity
{
    private GraphicalView mChartView;
    int num = 1;
    int tabnum = 0;
    int finalnum;
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabviews);
        LinearLayout ll = (LinearLayout) findViewById(R.id.buttons);
        Button button1 = new Button(this);
        button1.setText("Disease Type");
        ll.addView(button1);
        button1.setOnClickListener( new View.OnClickListener()
        {
            public void onClick(View v)
            {
                num = 1;
                Intent i = new Intent(PatientDemographics.this, TabHelper.class);
                i.putExtra("num", tabnum);
                startActivity(i);   
            }
        });
        Button button2 = new Button(this);
        button2.setText("Gender");
        ll.addView(button2);
        button2.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                num = 2;
                Intent i = new Intent(PatientDemographics.this, TabHelper.class);
                i.putExtra("num", tabnum);
                startActivity(i);
            }
        });
        Button button3 = new Button(this);
        button3.setText("Age at Diagnosis");
        ll.addView(button3);
        button3.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                num = 3;
                Intent i = new Intent(PatientDemographics.this, TabHelper.class);
                i.putExtra("num", tabnum);
                startActivity(i);
            }
        });
        Button button4 = new Button(this);
        button4.setText("Treatment Status");
        ll.addView(button4);
        button4.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                num = 4;
                Intent i = new Intent(PatientDemographics.this, TabHelper.class);
                i.putExtra("num", tabnum);
                startActivity(i);
            }
        });     
    }
}
Please ignore tabnum. It is used to determine the tab that everything is in, which is the same. Also, I originally created the buttons with xml, but each tab needed a different number of buttons and I didn't know how to do that so I just made them with code.
You can see that I initialize num to 1, then try to change it inside the onClick methods, but it never changes. Please let me know if you need any more information.
EDIT:
protected void onSaveInstanceState(Bundle outState)
{
      outState.putInt("num", num);
      super.onSaveInstanceState(outState);
}
And then in onCreate:
    super.onCreate(savedInstanceState);
    if(savedInstanceState != null)
    {
        num = savedInstanceState.getInt("num");
    }
 
     
     
    