Deleting Shared preferences in android -


in current app made set of passpoints , want there option delete them different activity. saw few questions similar on stackoverflow , tried follow instructions , tinker little nothing worked. wrong code?

first activity: ( activity preferences i'm trying delete )

public void setdefaults() {     sharedpreferences mprefs = getsharedpreferences(resett_passpoints, 0);     sharedpreferences.editor editor = mprefs.edit();     editor.putstring(resett_passpoints,identifier);     editor.commit(); } 

second activity : ( activity i'm trying delete )

public void deletedefaults(){      sharedpreferences mprefs = getsharedpreferences(activity1.resett_passpoints, 0);     string str = mprefs.getstring(activity1.resett_passpoints, activity1.identifier);     if (str.equals(activity1.identifier)){         sharedpreferences.editor editor = mprefs.edit();         editor.clear();         editor.commit();      }  } 

also, know use intents ".put extra" way of doing don't want start activity i'm deleting from

try replacing:

 if (str.equals(activity1.identifier)){         sharedpreferences.editor editor = mprefs.edit();         editor.clear();         editor.commit();         } 

for this:

 if (str.equals(activity1.identifier)){         sharedpreferences.editor editor = mprefs.edit();         editor.remove(activity1.resett_passpoints).commit();     } 

hope helps!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -