Reputation: 279
I am trying to delete a specific item from listView and from sharedPreferences on long item click.
ApplicationData.java
public static void remove(Context context,String dtl){
SharedPreferences sp = context.getSharedPreferences(PREFS_FILE, 0);
sp.edit().remove(dtl).commit();
ApplicationData.adapter.notifyDataSetChanged();
}
It says:
Error:(53, 32) error: method remove in class ApplicationData cannot be applied to given types; required: Context,String found: ,String reason: actual argument cannot be converted to Context by method invocation conversion
Upvotes: 0
Views: 461
Reputation: 12378
Can you try passing getApplicationContext() or getBaseContext() instead of this
ApplicationData.remove(this, dtl.toString());
Use this
ApplicationData.remove(getBaseContext(), dtl.toString());
Upvotes: 0