Surbhi
Surbhi

Reputation: 4078

How to maintain state of checkbox

My 1st activity is members personal information i have given chkbox for checking is local address is same as permanent address? if they r not same it should go to activity2 i.e permanent address screen. After filling all the details when i clicked on save button it should go to activity1 now i want that whatever i have filled in 1st activity should remain same also chkbox state and storing 2nd activity data in some variables in 1st activity class now i am storing activity1 and acitvity2 data in database.How to do it?

Upvotes: 1

Views: 167

Answers (1)

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

Use SharedPreferences for your requirement

To obtain shared preferences, use the following method In your activity:

SharedPreferences prefs = this.getSharedPreferences("store", 
                                                      Context.MODE_PRIVATE);

To edit and save preferences

boolean checkbox_state = true;
prefs.edit().putBoolean("KEY", checkbox_state ).commit();

To read preferences:

boolean state= prefs.getBoolean("KEY", false);;

Upvotes: 1

Related Questions