Android settings Add values ​​from database

One of the settings in my PreferenceActivity should get its values ​​from the database. How to add these values?

public class Settings extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preference_screen);

        ListPreference customPref = (ListPreference) findPreference("language");
        **ADD_CUSTOM_VALUES_HERE**????? 
    }
+3
source share
2 answers

ok I think I got it

listPreference.setEntries(entries)
listPreference.setEntryValues(entryValues)

where entries and entryValues ​​can be

 CharSequence[] entries = {'Entry 1','Entry 2','Entry 3','Entry 4'}; 
 CharSequence[] entryValues= {0,1,2,3}; 
0
source

Source: https://habr.com/ru/post/1756592/


All Articles