fasheikh
fasheikh

Reputation: 419

save the state of checkboxes in a list

I have a list with corresponding checkboxes, I would like to save the state of them so I can load the list of checked item when the app runs. How would I do this?

My onRetain looks like:

public Object onRetainNonConfigurationInstance() {
    return planets;
}

With planets being the entire list.

I have read up on SharedPreferences but I can't seem to get it working :(

Upvotes: 0

Views: 311

Answers (2)

SilentKiller
SilentKiller

Reputation: 6942

database::: Table name : state_checkBox

Fields position : int state : boolean

for code refer this links..

  1. Video

  2. example Code

you just have to update the state as "true" or "false" in the database but in getview all time you have to call a query to setChecked() the checkbox

& you hav to update the database on the checkedchangedlistner() of the checkbox...

Upvotes: 1

Tomer Mor
Tomer Mor

Reputation: 8028

if you want to store in persistence you should use D.B. like this

if you want only for the session you should use bundle, here in example

Upvotes: 0

Related Questions