Logout clear SharedPreferences

前端 未结 6 2095
清歌不尽
清歌不尽 2021-02-07 02:43

I have a login page that saves username and password to SharedPreferences. I have another Activity class that includes a logo

6条回答
  •  野的像风
    2021-02-07 02:54

    Try this !

    logout.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View view) {
                // Launching News Feed Screen
    
                 SharedPreferences preferences =getSharedPreferences("loginPrefs",Context.MODE_PRIVATE);
                 SharedPreferences.Editor editor = preferences.edit();
                 editor.clear();
                 editor.apply();
                 finish();
     });
    

提交回复
热议问题