RichardNewton
RichardNewton

Reputation: 886

Saving and restoring a list of preferences in Android

I have an Android settings screen (i.e. using classes related to the Preference class) where the user can configure 3 different colors. Each color is stored as an integer using the shared preferences functionality.

I want to let users save and restore the colors chosen (i.e. color schemes). At the top of the settings screen, I want a button that pops up a list of all current saved color schemes. Picking a color scheme would set the 3 color settings to the colors for that color scheme. If the user chooses to save the current colors, they are asked to name the color scheme and this color scheme will then appear in the color scheme selection list.

What's the simplest way to implement this functionality?

Upvotes: 1

Views: 642

Answers (1)

Robe Elckers
Robe Elckers

Reputation: 977

I think using the Android built-in SQLite database is your best option. You can create an SQL table colorscheme with 4 columns: id, color1, color2, color3. Then query the SQLiteDatabase.query method.

Have a look at the NotePad example at http://developer.android.com. Or at this tutorial.

Upvotes: 0

Related Questions