I set up SharedPreferences by following android documentation, requiring me to add each category to a string such as:
<string name="date_of_birth">com.test.activity.dateOfBirth</string>
But since I required a decent amount of variables to be stored and accessed from different activities, I created a class to handle SharedPreferences by following the guide here: https://stackoverflow.com/a/40446531/11019416
Have each variable defined in the SharedPref class as:
public static final String DATE_OF_BIRTH = "com.test.activity.dateOfBirth";
Calling the class in the relevant activity:
SharedPref.init(getApplicationContext());
Writing the necessary data to SharedPreferences:
String DATE_OF_BIRTH = eDateOfBirth.getText().toString();
SharedPref.write(SharedPref.DATE_OF_BIRTH, DATE_OF_BIRTH);
When I test retrieving the data in the next activity by changing a textview field to the DATE_OF_BIRTH variable, I get "com.test.activity.dateOfBirth" as a result instead of the date.
I have tried not using any predefined strings in strings.xml, along with saving the strings as different names, but cannot get it to save correctly.
Am I correctly using strings.xml with this? Or should the content of each string be blank?