I am using an activity to display the contact list, and inside this activity I have a button to add another contact. I can add a new contact and display it in the listview. But all the contacts will be gone if I exit the app or press the BACK button. 

I think I am having a problem while trying to get data from an Internal Storage. I can save the data and I can see the `CONTACT_LIST`s file in the Emulator. But I am not able to read the data from it. I put the "SavingFuction" in "OnPause" and "ReadingFunction" in "OnResume". I am using below code snippet for saving data:

For Internal storage:

onPause, onResume

```
@Override
protected void onPause()
{
    super.onPause();
    SavePreferences(arrContacts);
}

@Override
protected void onResume()
{
    super.onResume();
    getContact(arrContacts);
}

```

-Saving:

```
public void SavePreferences(ArrayList<Contacts> ct)
{
    try
    {
        FileOutputStream fOS = openFileOutput("CONTACT_LISTs", MODE_PRIVATE);
        ObjectOutputStream oOS = new ObjectOutputStream(fOS);
        oOS.writeObject(ct);
        oOS.flush();
        oOS.close();
        fOS.close();
    }
    catch(Exception e)
    {
        Log.e("InternalStorage", e.getMessage());
    }
}

```

-Reading

```
public void getContact(ArrayList<Contacts> ct)
{
    try
    {
        FileInputStream fIS = openFileInput("CONTACT_LISTs");
        ObjectInputStream oi = new ObjectInputStream(fIS);
        ct = (ArrayList<Contacts>) oi.readObject();
        oi.close();
        fIS.close();
    } catch (FileNotFoundException e) {
        Log.e("InternalStorage", e.getMessage());       
    } catch (IOException e) {
        Log.e("InternalStorage", e.getMessage()); 
    } catch (ClassNotFoundException e) {
        Log.e("InternalStorage", e.getMessage()); 
    }
}

```

How can I make it right?. Everything's just gone after I closed the app and reopened it.

this is my Contacts.java

```
    public class Contacts implements Serializable
    {

    private static final long serialVersionUID = 1L;
        private ArrayList<Contacts>contactList=new ArrayList<Contacts>();
        String name;
        String number;
        String address;

    public Contacts(String name, String num, String add)
    {
        this.name = name;
        this.number = num;
        this.address = add;
    }

    public Contacts() {

    }

    public void addContact(Contacts ct)
    {
        int i=0;
        for(; i < contactList.size(); i++)
        {
            Contacts nvOld=contactList.get(i);
            if(nvOld.getNum().trim().equalsIgnoreCase(ct.getNum().trim()))
            {
                break;
            }
        }
        if(i < contactList.size())
            contactList.set(i, ct);
        else
            contactList.add(ct);
    }

    String getName()
    {
        return name;
    }
    public void setName(String na)
    {
        this.name = na;
    }

    String getNum()
    {
        return number;
    }
    public void setNum(String nu)
    {
        this.number = nu;
    }

    String getAdd()
    {
        return address;
    }
    public void setAdd(String ad)
    {
        this.address = ad;
    }
}

```