about savedinstances
<p>Simple app with a variable (x) and 3 buttons (previous, next, random).</p>

<p>Everything ok but when I change oriented of mobile x goes to previous value and I don't understand why.</p>

<pre><code> @Override
 public void onCreate(Bundle savedInstanceState){ 
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

if (savedInstanceState != null) {
int x = savedInstanceState.getInt("x");

button4.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Random generator = new Random();

            int random = generator.nextInt(b);
            boolean flag = generator.nextBoolean();

            x=random;

            savePos();

            textView1.setText(""+prog[x]);/
 public void savePos(){
editor.putInt("x", x);
}
</code></pre>

<p>full code is huge, but should be ok for understand.</p>
