Charan Reddy Charan Reddy - 1 month ago 6x
Android Question

How the Activities are kept in preference screen settings

How can activities be saved in listView preferences so that when a User selects an activity in preferences so that when user starts the app next time they will appear as a first screen?


When user choose an Activity to save on it's preferences,You can save name of that Activity to sharedPreferences. Then in your MainActivity class when app runs again, check for saved activity and start that.

see this SO question

To save to preferences:

PreferenceManager.getDefaultSharedPreferences(context).edit().putString("MYACTIVITY", "myStringToSave").commit();

To get a stored preference:

PreferenceManager.getDefaultSharedPreferences(context).getString("MYACTIVITY", "defaultStringIfNothingFound"); 

where myStringToSave could be name of chosen activity