I'm trying to create a welcome screen. My problem is that everytime I re-open the application, it runs through the onCreate function again(code below) and re-initializes variables as if it were the first time again.I tried to use a counter with shared preferences but got the same result.My idea was that my application would run through the Oncreate method on the first load then create a boolean named firstBoot = true .Which would then be changed to false, but how can i test if a boolean is false if it does not exist yet? Any help would be greatly appreciated.
(within onCreate Method)
final String PREFS_NAME = "MyPrefsFile";
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
if (settings.getBoolean("my_first_time", true)) {
//the app is being launched for first time, do something
Log.d("Comments", "First time");
// first time task
setContentView(R.layout.setup);
// record the fact that the app has been started at least once
settings.edit().putBoolean("my_first_time", false).commit();
}
else
{
setContentView(R.layout.test);
}