user1798790
user1798790

Reputation: 41

Android Preference Screen without XML

I want to create a preferences screen without writing an XML layout file. I'd like to store the settings in a SQLite database. Is this possible?

Upvotes: 4

Views: 964

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234795

You can simply create a preference hierarchy (probably in onCreate() for the PreferenceFragment) with:

PreferenceScreen screen = new PreferenceScreen();

and add preference items to screen using addPreference. In the PreferenceFragment (or PreferenceActivity, if you aren't using fragments), just call setPreferenceScreen with the hierarchy after it's constructed.

Upvotes: 1

Related Questions