Android, Save ArrayList for when reopening app
<p>I'm creating an app wich is supposed to do the following:<br>
- When started shows a splash/info-activity.<br>
- In next activity shows a list of names as checkboxes<br>
- user can add new names via EditText &amp; Add-button (list updated dynamically)<br>
- When closing app, and reopening, names previously added should be saved and displayed in list.<br>
I've tried to setup my list as ArrayList in my startingactivity just to see if I can save and load my information correctly:</p>

<pre><code>public class StartActivity extends Activity implements OnClickListener {
Typeface face;
TextView tvStartIntrotext;
Button bStartStart;

ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();

String NAMESFILE = "names_file";
FileOutputStream fos;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.startactivity);

    face = Typeface.createFromAsset(getAssets(), "andalemono.ttf");
    bStartStart = (Button) findViewById(R.id.bStartStart);
    bStartStart.setTypeface(face);
    tvStartIntrotext = (TextView) findViewById(R.id.tvStartIntrotext);
    tvStartIntrotext.setTypeface(face);
    bStartStart.setOnClickListener(this);

    try {
        fos = openFileOutput(NAMESFILE, Context.MODE_PRIVATE);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        names.add("Name Name");
        oos.writeObject(names);
        oos.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.startactivity, menu);
    return true;
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent startIntent = new Intent(StartActivity.this, Choose.class);
    startActivity(startIntent);
}
}
</code></pre>

<p>To read and display I have this in my other activity so far:  </p>

<pre><code>public class Choose extends Activity implements OnClickListener {

String NAMESFILE = "names_file";
FileInputStream fis;

Button bChooseChoose, bChooseAdd;
Typeface face;
TextView tvChoosePick;
EditText etChooseAddnew;
LinearLayout llMain;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.slideinright, R.anim.slideoutleft);
    setContentView(R.layout.choose);


    face = Typeface.createFromAsset(getAssets(), "andalemono.ttf");
    bChooseChoose = (Button) findViewById(R.id.bChooseChoose);
    bChooseChoose.setTypeface(face);
    bChooseChoose.setOnClickListener(this);
    bChooseAdd = (Button) findViewById(R.id.bChooseAdd);
    bChooseAdd.setTypeface(face);
    bChooseAdd.setOnClickListener(this);
    tvChoosePick = (TextView) findViewById(R.id.tvChoosePick);
    tvChoosePick.setTypeface(face);
    etChooseAddnew = (EditText) findViewById(R.id.etChooseAddnew);
    etChooseAddnew.setTypeface(face);
    etChooseAddnew.setBackgroundResource(R.color.white1);
    etChooseAddnew.setHintTextColor(color.greytext);
    llMain = (LinearLayout) findViewById(R.id.llMain);


    try {
        fis = openFileInput(NAMESFILE);
        ObjectInputStream ois = new ObjectInputStream(fis);
        ArrayList&lt;Object&gt; names = (ArrayList&lt;Object&gt;) ois.readObject();            

        ois.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    for (int i = 0; i &lt; names.size(); i++) {
        CheckBox cbb = new CheckBox(this);
        cbb.setText(names.get(i));
        cbb.setTypeface(face);
        cbb.setTextSize(16);
        llMain.addView(cbb);
    }

}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()){
    case R.id.bChooseChoose:

        break;
    case R.id.bChooseAdd:

                   /*This button for adding new list name*/

        break;
    }

    }
}
</code></pre>

<p>One error I'm getting at this point is "setText" in my for-loop. Don't yet know how to get the information from the file opened to display in a list correctly. Although the for-loop works when no fileInput/Output is used.<br>
Any pointers to what I can try would be really helpful, since I'm new to Android programming. :)<br>
Thx!</p>
