I searched in google. i can find an answer for clearing the shared preference but i need to clear the shared preferences when app getting closed. is this possible pls help.
code clear shared preference
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("UserName", "Tonny");
editor.putInt("UserAge", 20);
editor.commit();