Android : Android String reference to shared preferences cannot be iterated?

on Monday, November 3, 2014


So I have an ArrayList named locationsList. I also have SharedPreferences that hold a city name which was set in the previous activity which i want to add onto my ArrayList. BUT I want to add it with a ">" at the end of it. So for example



SharedPreferences prefs = getActivity().getSharedPreferences("prefs", 0);
locationsList.add(0, prefs.getString("city", "no city") + ">");


However it does not change!!!. the ">" Isn't added. I even tried adding it when i set the text of the textView.



TextView tv...;
tv.setText(locationsList.get(0) + ">");


I dont understand why it cant change. Obviously the array list is holding a reference to the preferences and that cannot change. But I even tried assigning the preferences to a string variable and then iterating it, it doesn't budge. Can anyone help me


0 comments:

Post a Comment