How to save data in a listView
<p>I created a listView that is based on the user input. User has to enter text in an editText and then it's added into the list. It works great. My question though, is how do I save this data so even when they close the app, and then open it back up again, the listView still has the items in it from last time? Here is my code: </p>

<p>MainActivity.java</p>

<pre><code>    package com.kass.planner2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends Activity implements View.OnClickListener {

    private Button btn;
    private EditText et;
    private ListView lv;
    ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
    ArrayAdapter&lt;String&gt; adapter;

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

        btn = (Button)findViewById(R.id.button);
        btn.setOnClickListener(this);
        et = (EditText)findViewById(R.id.editText);
        adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_expandable_list_item_1, list);

        // set the lv variable to your list in the xml
        lv=(ListView)findViewById(R.id.listView);
        lv.setAdapter(adapter);
    }
    public void onClick(View v)
    {
        String input = et.getText().toString();
        if(input.length() &gt; 0)
        {
            // add string to the adapter, not the listview
            adapter.add(input);
            // no need to call adapter.notifyDataSetChanged(); as it is done by the adapter.add() method
        }
    }


}
</code></pre>

<p>activity_main.xml</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.kass.planner2.MainActivity"
    android:weightSum="1"&gt;

    &lt;RelativeLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_weight="1.12"&gt;

        &lt;EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/editText"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="60dp"
            android:layout_alignEnd="@+id/button" /&gt;

        &lt;Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button"
            android:layout_centerVertical="true"
            android:layout_alignParentStart="true"
            android:onClick="saveEvent"/&gt;

        &lt;ListView
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:id="@+id/listView"
            android:layout_centerVertical="true"
            android:layout_alignParentEnd="true"
            android:layout_toEndOf="@+id/editText" /&gt;
    &lt;/RelativeLayout&gt;


&lt;/LinearLayout&gt;
</code></pre>

<p>Thank you.</p>