How to display only one time Login and then after start application directly in android

后端 未结 6 2144
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 15:34

I am getting trouble in making only one time login... My aim is first user gets login screen.. If he is new user he will register and then login...from then when ever user s

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 15:51

    You can visit my blog

    http://upadhyayjiteshandroid.blogspot.in/2013/01/android-working-with-shared-preferences.html

    hope you will get the answer and understanding clearly

    Boolean flag;
    
    SharedPreferences applicationpreferences = PreferenceManager
                .getDefaultSharedPreferences(MainActivity.this);
    
    SharedPreferences.Editor editor = applicationpreferences .edit();
    
    flag = applicationpreferences .getBoolean("flag", false);
    
    if (flag) {
    ///second time activity
    
    }else{
    //first time
    editor.putBoolean("flag", true);
    editor.commit();
    }
    

提交回复
热议问题