Search code examples
androidsqlitedynamicpreference

Using Android Preference classes UI for configuring dynamic data


For configuring a row of a database table, I'd like to use a UI identical to the Android Preference classes UI. For example, this would be setting a bunch of checkboxes / radios / etc to configure an alarm, in a table that held a number of user-created alarms.

Is it possible and/or appropriate to use the Preference classes for this, rather than manually building my own forms to mimic the UI? I want the UI to look as 'standard' as possible across the range of Android versions.


Solution

  • Pass the row id from the previous activity and set OnPreferenceChangeListener for each preference, and and every time Preference changes you can update the row.

    You could also pass back all values from the preferenceActivity to the calling activity through setResult and update row in OnActivityResult