Last active
June 7, 2017 15:58
-
-
Save krupalshah/7d408a8ca27649c04d81c1ec1edd5ca2 to your computer and use it in GitHub Desktop.
helper for shared prefs - java version - Refactoring step 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void edit(Context context, Performer<SharedPreferences.Editor> performer) { | |
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); | |
SharedPreferences.Editor editor = sharedPreferences.edit(); | |
performer.performOperation(editor); | |
editor.apply(); | |
} | |
public interface Performer<T> { | |
void performOperation(T victim); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment