I am new to Android, and this question may be easy to solve, but I have been searching and trying for more than 4 hours to get data.
I want to use MultiSelectListPreference to create an array of elements and search them in xml.
I created a MultiSelectListPreference in XML (res / xml / preferences.xml)
<MultiSelectListPreference android:dialogTitle="@string/coursesTitle" android:key="searchedCourses" android:summary="" android:title="@string/coursesTitle" android:entries="@array/courses" android:entryValues="@array/courses" android:defaultValue="@array/empty_array" android:dependency="own_courses" />
I created a preference fragment and a preference function. I can already select the items I want to find.
Now I want to read the selected items.
I tried using
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String rawval = sharedPref.getString("searchedCourses", "NA"); String[] selected = this(context, null).parseStoredValue(rawval); Toast.makeText(context, selected[0], Toast.LENGTH_LONG).show();
and similar "solutions" that I found on the Internet, but this does not work.
I hope you understand me, and you can help me. Thanks and greetings from Germany.
source share