Basically I am making an app that calculates compound interest for different amounts of money. There are 2 'Shared Preferences' if you will.
setup - for the user to enter interest rate, compounding frequency, term
preferences - for app setting (eg. show cents or not, set background color)
The program I am having is when I had one set of preferences it worked fine. However when I had two (when I created 'preferences'), it messed up the first set up preferences, called 'setup'.
Also, whenever it retrieves the preferences it is in a fragment.
Here is how I was getting preferences (When I didn't have the 2 preference xml's):
SharedPreferences getSetup = PreferenceManager.getDefaultSharedPreferences(getActivity().getBaseContext());
String t2 = getSetup.getString("rate", null);
Here is the solution I tried (opening the specific file and then of course using getSetup or getPrefs.getString("key, null")- it didn't work and always returned the default value)
SharedPreferences getPrefs = getActivity().getSharedPreferences("preferences",0);
and for setup
SharedPreferences getSetup = getActivity().getSharedPreferences("setup",0);
Whenever I run the app, I get my error message ("please properly setup the app and enter all vales") This error message was setup to run with the following code:
SharedPreferences getSetup = getActivity().getSharedPreferences("setup",0);
int t1 = value1.getText().length();
int t1_2 = value2.getText().length();
String t2 = getSetup.getString("rate", null);
String t3 = getSetup.getString("retirement", null);
String t4 = getSetup.getString("compounds", null);
String t5 = result.getText().toString();
if (t1 == 0 ||t1_2 ==0 || t2 == null || t3 == null || t4 == null) {
//show the error message
Can someone please inform me what I am doing wrong and how I could get the specific set of preferences.
Cheers