Search code examples
androidsharedpreferencesviewflipper

Can sharedPreferences be implemented with viewflipper? How?


I'm planning to keep a splash screen to my app but the screen should run only once in it's entire life cycle (i.e starting from first run to delete of the app it will run once that also in the first run of the application)

I did make the splash screen but sharedPreferences is new to me so can anyone plz help me with this


Solution

  • Try this:

    SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE);
    
    boolean firstTime = pref.getBoolean("firstTime", true);
    
    if(firstTime){
    //do something
    
    pref.edit().putBoolean("firstTime",false).commit();
    }