My application requires initial user setup, for the first time the app is opened by the user. He should be able to do some initial setup that will determine how the application is run. For this, I am using sharedPreferences. What Im doing is simply, setting the contentView depending on if the boolean is 'true' or false'. But the question i have is in regards to what happens after i setContentView().
//Variables
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//creating sharedpref file
PREFS_NAME = "MyPrefsFile";
shPref = getSharedPreferences(PREFS_NAME, 0);
shPref.edit().putBoolean("my_first_time", true).commit();
//checking if app's being launched for first time
if(shPref.getBoolean("my_first_time", true)) {
setContentView(R.layout.page_one);
//setting the shPref as false
shPref.edit().putBoolean("my_first_time", false).commit();
}
//checking if app has been launched before
else if(shPref.getBoolean("my_first_time", false) && shprefchecker == 1) {
setContentView(R.layout.home_page);
}
}
So what I want to do is wait for the user to finish setup before I can set the shPref as false. Im guessing that once the layout is changed in this line " setContentView(R.layout.page_one);", it will automatically set the shPref as false. I want the app to not do anything until the user has gone through the initial setup (first layout in the intial setup is page_one.xml).
I might sound confusing, but how would I do this? Please help. All answers are appreciated. Thanks!