In MainActivity I press on a button, then a dialog (a class that extends DialogFragment
) will be opened. In that dialog, I press a button and a value will be saved as SharedPrefernece. Now when I close that dialog, I want to read that saved value in MainActivity.
This is how I tried it but my code will not run when I close the dialog.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println(Helper.getSharedPreference(getApplicationContext(), "dialog"));
So how can I refresh MainActivity?