I have a small android app that I am trying to create and I need to save some values from one activity and pass them back to the main activity. I looked into shared preferences and I couldn't get it to work. I am not sure if that is the best method, I have a class that I would prefer to store the data in but I am not sure how to access a single instance of a class between multiple classes so I was going to go with the shared preferences method.
Here a method I have in my second activity that I thought would work but doesn't.
public void saveInfo(View view){
SharedPreferences sharedPref = getSharedPreferences("PatientData", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("Auditory-1stepq1", auditory1stepQ1);
editor.apply();
System.out.format("auditory1stepQ1: %I", auditory1stepQ1);
Toast.makeText(this, "saved!", Toast.LENGTH_SHORT).show();
}
Does anyone know a simple method for storing data between multiple classes using Android resources, I would do a flat file it was easy enough.