To get all stored values use the method getAll() of Sharedpreferences:
Map<String,?> map = prefs.getAll();
For a list of values use:
List<Value> list = new ArrayList<Value>(map.values());
Use the list to build the Listview as usual.
If you want to get the list from Keys use:
List<Value> list = new ArrayList<Value>(map.keys());
Android provides the api Preferences to program an interface of the "system settings".
Instead of using objects View to create the user interface, the settings are created through several subclasses of the class Preference declared in an XML file.
To display the preferences list is used a Preferenceactivity(API < 10) or Preferencefragment(API >= 10).
To documentation has an article in which explains in detail how to do it.
This I did and I’m using the log to check the received data, and everything ok. My problem is in Listactivity when I use Simpleadapter to display values in listview.
– Tadeu
Can you edit your question with the snippet of the code in question?
SharedPreferences
, the snippet of you getting these values and the snippet of you trying to put in theAdapter
– Marllon Nasser
Could you show the data structure you’re working on? What are you saving !
– Thiago Luiz Domacoski
Thiago,
SharedPreferences
is based on keeping small information, identified by a "Key". That is, I keep the following:Chave: Valor
. I mean, I keep a certain value given a reference name.ReferenciaX: ValorXPTO
– Marllon Nasser
Yes, I know that, but how are you willing, these values? Look at my answer and see if it helps you! Hugs!
– Thiago Luiz Domacoski