[Solved] How to use shared preference to send data from activity to fragment?


If you insist on shared preference use this code :

To save the data

 private void saveSp(String key , String value){
 PreferenceManager.getDefaultSharedPreferences(Context)
            .edit()
            .putString(key, value).apply();
}

To get your data:

PreferenceManager.getDefaultSharedPreferences(Context).getString("string", "default")

solved How to use shared preference to send data from activity to fragment?