@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); ArrayList<String> vals = new ArrayList<String>(); ArrayList<Integer> ids = new ArrayList<Integer>(); int newone = 0; for (int i = 0; i < max; i++) { if (!checkFiles(i)) { newone = i; ids.add(i); vals.add(thetexts.get(i).edit.getText().toString()); } else if (thetexts.get(i).changed) { ids.add(i); vals.add(thetexts.get(i).edit.getText().toString()); } } if (newone > 0) outState.putInt("newone", newone); outState.putStringArrayList("vals", vals); outState.putIntegerArrayList("ids", ids); if (curfocus != null) outState.putInt("curfocus", curfocus.getId()); outState.putBoolean("OKAY", true); }