ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 12 - Associate Android Developer discussion

Report
Export

For example, our preferences.xml file was added by addPreferencesFromResource(R.xml.preferences). Our preferences.xml file contains such item:

<ListPreference android:id="@+id/order_by" android:key="@string/pref_sort_key" android:title="@string/pref_sort_title" android:summary="@string/pref_sort_summary" android:dialogTitle="@string/pref_sort_dialog_title" android:entries="@array/sort_oder" android:entryValues="@array/sort_oder_value" android:defaultValue="@string/pref_default_sort_value" app:iconSpaceReserved="false" />

In our Fragment, we can dynamically get current notification preference value in this way:

A.
val sortBy = PreferenceManager.getDefaultSharedPreferences(context).getString( context!!.getString(R.string.pref_sort_key),context!!.resources.getBoolean(R.bool.pref_default_sort_value) )
Answers
A.
val sortBy = PreferenceManager.getDefaultSharedPreferences(context).getString( context!!.getString(R.string.pref_sort_key),context!!.resources.getBoolean(R.bool.pref_default_sort_value) )
B.
val sortBy = PreferenceManager.getSharedPreferences(context).getString( context!!.getString(R.string.pref_default_sort_value), context!!.getString(R.string.pref_sort_key), )
Answers
B.
val sortBy = PreferenceManager.getSharedPreferences(context).getString( context!!.getString(R.string.pref_default_sort_value), context!!.getString(R.string.pref_sort_key), )
C.
val sortBy = PreferenceManager.getSharedPreferences(context).getBoolean( context!!.resources.getBoolean(R.bool.pref_default_sort_value),context!!.getString(R.string.pref_sort_key) )
Answers
C.
val sortBy = PreferenceManager.getSharedPreferences(context).getBoolean( context!!.resources.getBoolean(R.bool.pref_default_sort_value),context!!.getString(R.string.pref_sort_key) )
D.
val sortBy = PreferenceManager.getDefaultSharedPreferences(context).getString( context!!.getString(R.string.pref_sort_key), context!!.getString(R.string.pref_default_sort_value) )
Answers
D.
val sortBy = PreferenceManager.getDefaultSharedPreferences(context).getString( context!!.getString(R.string.pref_sort_key), context!!.getString(R.string.pref_default_sort_value) )
Suggested answer: D
asked 18/09/2024
Nadja Burkart
32 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first