Reputation: 8448
I'm trying to design an application that saves the selection I made on a Spinner even if the application changes (I launch a different one) or I simply navigate between it's differents Activities, including pressing "Back" on my application.
int ALARM_REPEAT = 7;
ArrayAdapter myAdap = (ArrayAdapter) spinFrecEnvio.getAdapter();
int pos = myAdap.getPosition(ALARM_REPEAT);
spinFrecEnvio.setSelection(pos);
This code refers for the first time I start the Activity with the Spinner. When I change it, how can I make the selection persistent??
Thank you.
Upvotes: 0
Views: 479
Reputation: 11107
You can use Shared preference for Storing you Selected value. When User come backs to you Spinner Activity you can get the value from Shared preference and bind it to Spinner.
It simply a name/value pair.
If you need to store larger data you can go for SQLite for Storing and Bind it back.
For Shared preference Check this .
Also refer this link
Upvotes: 1