At the press of back button the new entries in the ListView are gone
<p>I have a <code>listview</code> which is initialized with few entries. In the <code>menu</code> bar I have an option for adding more entries for which a <code>dialog</code> is opened and I have to enter three fields. On clicking the <code>save</code> button the entries are displayed in the <code>listview</code> but on pressing the back button and after restarting the app the older <code>listview</code> is displayed ,i.e, the newly entered values in the <code>listview</code> are not displayed.</p>

<p>The main code :</p>

<pre><code>   public class SecondScreen extends ListActivity implements AppCompatCallback,AdapterView.OnItemClickListener {

    private Toolbar bar;
    private AppCompatDelegate delegate;
    List&lt;Model&gt; list;
    Model selectedModel;
    AGSQLiteHelper db;
    Adapter adapter;
    private EditText task_Title,task_Description,task_Date;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        delegate=AppCompatDelegate.create(this,this);
        super.onCreate(savedInstanceState);
        //savedInstanceState.putBoolean("mIsBackButtonPressed",mIsBackButtonPressed);
        delegate.setContentView(R.layout.activity_second_screen);
        bar=(Toolbar)findViewById(R.id.toolbarID);
        delegate.setSupportActionBar(bar);
        ActionBar ab=delegate.getSupportActionBar();
        ab.setDisplayHomeAsUpEnabled(true);
        db=new AGSQLiteHelper(this);
        db.onUpgrade(db.getWritableDatabase(),1,2);
        db.createTask(new Model("abcde","description abcde","19/11/12"));
        db.createTask(new Model("bcdese","description bcdese","18/12/12"));
        db.createTask(new Model("mnbv","description mnbv","2/11/10"));
        db.createTask(new Model("poiuy","description poiuy","1/5/6"));
        list=db.getAllTasks();
        adapter=new Adapter(this,R.layout.row,list);
        getListView().setOnItemClickListener(this);
        setListAdapter(adapter);

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    @Nullable
    @Override
    public View onCreateView(String name, Context context, AttributeSet attrs) {

        return super.onCreateView(name, context, attrs);
    }

    @Override
    public void onSupportActionModeStarted(ActionMode mode) {

    }

    @Override
    public void onSupportActionModeFinished(ActionMode mode) {

    }

    @Nullable
    @Override
    public ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback) {
        return null;
    }

    @Override
    public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if(item.getItemId()==R.id.add){
            Toast.makeText(getApplicationContext(),"Add was clicked",Toast.LENGTH_LONG).show();

            final Dialog dialog=new Dialog(SecondScreen.this);
            dialog.setContentView(R.layout.custom_dialog);
            dialog.setTitle("Dialog");
            Button save_button=(Button)dialog.findViewById(R.id.saveButtonID);
            Button cancel_button=(Button)dialog.findViewById(R.id.cancelButtonID);

            task_Title=(EditText)dialog.findViewById(R.id.titleEditTextID);
            task_Description=(EditText)dialog.findViewById(R.id.descriptionEditTextID);
            task_Date=(EditText)dialog.findViewById(R.id.dateEditTextID);

            dialog.show();

            save_button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    selectedModel=new Model();
                    selectedModel.setTask_title(task_Title.getText().toString());
                    selectedModel.setTask_description(task_Description.getText().toString());
                    selectedModel.setTask_date(task_Date.getText().toString());
                    db.insertTask(selectedModel);
                    //Toast.makeText(getApplicationContext(),"model ="+selectedModel.getTask_title(),Toast.LENGTH_LONG).show();
                    //Log.i("Second Screen","list length before "+list.size());
                    //list=db.getAllTasks();
                    list.add(selectedModel);
                   // Log.i("Second Screen","list length after "+list.size());
                   // Adapter adapter =( Adapter)getListView().getAdapter();
                    //adapter=new Adapter(this,R.layout.row,list);
                    adapter.notifyDataSetChanged();
                    //Toast.makeText(getApplicationContext(),"model ="+selectedModel.getTask_title(),Toast.LENGTH_LONG).show();
                    dialog.dismiss();
                }
            });

            cancel_button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
        }

        if(item.getItemId()==R.id.done){
            Toast.makeText(getApplicationContext(),"Done was clicked",Toast.LENGTH_LONG).show();
        }
        return true;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu,menu);
        return true;
    }


}
</code></pre>

<p>Any suggestions?</p>