i want to set a value when app launching.i.e. in my application i have to select a location name when app launching.My problem is when app is launching there should be an option to select the place and according that place my app should load the details.but it should done on first time launching only.And we close the app and reopen it should not ask the location again it should open with previous selected location details.ofcourse inside the app there is an option to change the location.How to do it pls help me. Thanks in advance.
Asked
Active
Viewed 266 times
1 Answers
1
you can save location value into SharedPreferences when first time user select location.
see this link for sample example.
So next time when application launch then check the SharedPreferences value and render UI according to SharedPreferences value.

Community
- 1
- 1

Vivek Kumar Srivastava
- 2,158
- 1
- 16
- 23
-
thanks for your reply.I just show a simple message like a dialog alert first time(only once at the time of installing the app) and it won't show again whenever we reopen the app i.e.after launching the app a dialog will appear and it shows message like selected location is Washington.Do u want to change the location?if yes go the settings options in my menu,if no stay in that location only.Please help me with an sample example. – user484848 Jul 24 '12 at 04:48
-
that's what i was saying. can you put your starting activity code so other developer able to suggest changes? – Vivek Kumar Srivastava Jul 24 '12 at 05:06
-
public static final String PREFS_NAME = "MyPrefsFile"; SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); boolean dialogShown = settings.getBoolean("dialogShown", false); if (!dialogShown) { showDialog(DIALOG_ALERT_SELECT_LOCATION); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("dialogShown", true); editor.commit(); } Its worked for me. – user484848 Jul 25 '12 at 11:44