user1242359
user1242359

Reputation: 21

Save Checkboxes state in ListView and Retrieve it back when come back to class using Shared preferences

I Got stucked in saving the Checkboxes state and getting back in listview, i want to save what all the items were checked and save it and get it back when the Activity is called again... Pls help me in this with sample code... any help will be very usefull for me.

Upvotes: 0

Views: 297

Answers (1)

Sai mukesh
Sai mukesh

Reputation: 722

Here is the sample code(But not using sharedPreferences)

    public class SavedInstanceDemo extends Activity{

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            //retrieve values from savedInstanceState

            Boolean isChecked=savedInstanceState.getBoolean("isChecked",false);

        }

        @Override
        public void onSaveInstanceState (Bundle outState){
            //save your requires values into this outState which can be retrieved on next time
            outState.putBoolean("isChecked", true);
        }

    }

Upvotes: 2

Related Questions