(Android) I have questions about ListView and SharedPreference : I am a beginner developer who is studying Android.

The function I want to develop is "Save the data entered in EditText as JSON, save it as SharedPreference, and output it to ListView".

To save it as SharedPreference is OK, but, To output it to ListView is not working now.

Please give a lot of advice.


MainActivity.java : 

public class MainActivity extends AppCompatActivity {

    private ListView listView;
    private Button save_btn;
    private ArrayList<List> data = new ArrayList<List>();

    ListAdapter adapter;

    String title="";
    String info="";
    int img = R.drawable.man;

    String jsondata;

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

        listView = (ListView) findViewById(R.id.listView);
        save_btn = (Button) findViewById(R.id.button1);

        loadArrayList(getApplicationContext());

        adapter = new ListAdapter(this, R.layout.row, data);
        listView.setAdapter(adapter);

        registerForContextMenu(listView);


        save_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                View dlgview = View.inflate(MainActivity.this, R.layout.adds, null);

                //adds.xml
                final EditText et_title = (EditText) dlgview.findViewById(R.id.editText1);
                final EditText et_info = (EditText) dlgview.findViewById(R.id.editText2);
                ImageView img1 = (ImageView) dlgview.findViewById(R.id.imageView2);

                AlertDialog.Builder dlg = new AlertDialog.Builder(MainActivity.this);

                dlg.setTitle("ADD");
                dlg.setView(dlgview);
                dlg.setNegativeButton("Save", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                        JSONObject jsonObject = new JSONObject();
                        JSONArray jsonArray = new JSONArray();

                        try{
                            jsonObject.put("title", et_title.getText().toString());
                            jsonObject.put("info", et_info.getText().toString());
                            jsonObject.put("image",img);

                            jsonArray.put(jsonObject);

                        } catch (JSONException e){
                            e.printStackTrace();
                        }

                        jsondata = jsonArray.toString();

                        saveArrayList();
                        adapter.notifyDataSetChanged();

                    }
                });
                dlg.setPositiveButton("Cancel",null);
                dlg.show();
            }
        });


    }//End of onCreate


    private void saveArrayList(){

        SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = sharedPrefs.edit();

        editor.putString("jsonData", jsondata);
        Log.i("moi","get Data test : " + "jsonData");

        editor.apply();

    }

    
    private void loadArrayList(Context context){
        SharedPreferences sharedPrefs2 = PreferenceManager.getDefaultSharedPreferences(context);
        int size = sharedPrefs2.getInt("appreciation_size",0);
        String strJson = sharedPrefs2.getString("jsonData", "fail");
        Log.i("moi","get SharedPreferences test : " + strJson);

        if (strJson != "fail")
        {
            try {
                JSONArray response = new JSONArray(strJson);
                for (int i=0; i<size; i++)
                {
                    JSONObject jsonobject = response.getJSONObject(i);
                    title   = jsonobject.getString("title");
                    Log.i("moi","title test : " + "title");
                    info    = jsonobject.getString("info");
                    Log.i("moi","info test : " + "info");
                    data.add(new List(title, info, img));
                }
                adapter = new ListAdapter(getApplicationContext(), R.layout.row, data);
                listView.setAdapter(adapter);
            } catch (JSONException e){
                e.printStackTrace();
            }
        }


    }



}//End of class