• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Shared preferences

Rakesh K

Lurker
hi,
I am developing an application, where i receive the notification using notification listerner and comparing the text with the value in shared preferences. I am facing a problem where i cannot clear the shared preferences value which i click a button to clear it. It is showing the very first value stored in the shared preference.
Can anyone help me with this, how to delete the shared preferences value without uninstalling or restarting the application
 
hi,
I am developing an application, where i receive the notification using notification listerner and comparing the text with the value in shared preferences. I am facing a problem where i cannot clear the shared preferences value which i click a button to clear it. It is showing the very first value stored in the shared preference.
Can anyone help me with this, how to delete the shared preferences value without uninstalling or restarting the application

On your Activity class you can use this to delete a specific part of the shared preferences when called anywhere:

Code:
SharedPreferences gamePrefs = getSharedPreferences("GAMEPREFS", MODE_PRIVATE);
        SharedPreferences.Editor editor = gamePrefs.edit();
        editor.remove(PREF_SAVED_ITEM);
        editor.commit();
 
Back
Top Bottom