I have declared two share preferences within an activity. The two shared preferences are controlled with a logic if block as shown
if(logic == true){
// remove shared preferences of a particular keyname
SharedPreferences sharedPreferencesGiver = getSharedPreferences("editorCodeGiver", Context.MODE_PRIVATE);
//assuming that editorCodeGiver is the name of the shared preferences declared below in the else block
SharedPreferences.Editor editGiv = sharedPreferencesGiver.edit();
editGiv.clear().commit();
}else{
//dont clear shared preferences
SharedPreferences sharedPrefCodeGiver = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editorCodeGiver = sharedPrefCodeGiver.edit();
editorCodeGiver.putInt("statusCodeGiver", 202); //
editorCodeGiver.commit();
}
Please how can I clear the shared preferences declared in the else block