I am currently new to android and am working on a note taker application so please be patient with me. Inside the menu, i implemented an option whereby the user can change view if desired (List or Grid).

```
 LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View customTitleView = inflater.inflate(R.layout.dialog_menu, null);
        mListViewSelect = (LinearLayout) customTitleView.findViewById(R.id.list_select);
        mGridViewSelect = (LinearLayout) customTitleView.findViewById(R.id.grid_select);
case R.id.changeView:
                final AlertDialog alertbox = new AlertDialog.Builder(this).create();
                alertbox.setCancelable(true);
                alertbox.setView(customTitleView);
                alertbox.show();
                mListViewSelect.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mListNotes.setVisibility(View.VISIBLE);
                        mGridNotes.setVisibility(View.GONE);
                        alertbox.dismiss();
                    }
                });
        mGridViewSelect.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mListNotes.setVisibility(View.GONE);
        mGridNotes.setVisibility(View.VISIBLE);
        alertbox.dismiss();
    }
});
        }
        return super.onOptionsItemSelected(item);
    }

```

This works perfectly. However, i want the app to open in the selected view initially selected by user. For example, if the user had closed the app while in gridview, the app should open in gridview while restarted. 

I understand i need to save data persistently with shared preferences or something. But i need to know exactly what i need to do.