I'm trying to delete shared preferences on another activity when the user press logout button. First I added my variables to the SharedPreferences, related code is below.

```
SharedPreferences shared_preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                            SharedPreferences.Editor editor = shared_preferences.edit();
                            int id = Integer.parseInt(cursor.getString(0));
                            String name = cursor.getString(1);
                            String surname = cursor.getString(2);
                            String email = cursor.getString(3);
                            String username = cursor.getString(4);
                            String password = cursor.getString(5);
                            byte[] photograph = cursor.getBlob(6);
                            String saveThis = Base64.encodeToString(photograph, Base64.DEFAULT);
                            editor.putInt("id",id);
                            editor.putString("name",name);
                            editor.putString("surname",surname);
                            editor.putString("email",email);
                            editor.putString("username",username);
                            editor.putString("password",password);
                            editor.putString("photograph",saveThis);
                            editor.commit();
                            login_screen = new Intent(Login.this, NavigationDrawer.class);
                            startActivity(login_screen);

```

Now, I will delete the all variables from the SharedPreferences but when I trying to login in different account nothing happens and all my data is still in SharedPreferences. How will I delete all variables ? Here is the code 

```
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                            SharedPreferences.Editor editor = preferences.edit();
                            editor.clear();
                            editor.commit();
                            Intent moveToMain = new Intent(getApplicationContext(), Login.class);
                            moveToMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |  Intent.FLAG_ACTIVITY_CLEAR_TASK);
                            startActivity(moveToMain);

```