I am building an app which can allow people of the same interest to meet with each other. Now there is this page which consists of various interest (example – gaming, coding, singing, and sports) for the user to choose from.
The user can only choose one interest and they would be redirected to the particular interest main activity. But what’s happening is whenever I’m restarting the app I am seeing that interest page coming up (every time I open the app) what do I do so that I never see that page again after I chose one of the interest.
Example code would be so appreciated.
I recently got to know about sharedPreference, but I still have no idea where and how I would use it. What would be a detailed explanation if I have four activities, let’s say gameActivity, singActivity, sportsActivity, and codeActivity. How would I use sharepreference to never see the interest page again?
2
Answers
User preferences like this are what shared preferences are designed for. They are already very well documented with examples here – https://developer.android.com/training/data-storage/shared-preferences
The way you could use shared preferences to achieve the behaviour you describe could look something like this, but given I know little about how you’ve designed your app, it may not fit you well:
Obviously these app startup checks need to go somewhere, so you can add a "StartupActivity" which doesn’t actually create any UI, just contains the logic for deciding which activity to launch next.
You can use SharedPreferences.