Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.mathapplication;
- import android.content.Context;
- import android.content.SharedPreferences;
- public class Settings {
- private static final String PREFERENCE_FILE_NAME = "com.example.mathapplication.Settings";
- static int min = 10;
- static int max = 10;
- static boolean add = true;
- static boolean sub = true;
- static boolean mul = true;
- static boolean div = true;
- static void saveSettings(Context context) {
- SharedPreferences sharedPref = context.getSharedPreferences(PREFERENCE_FILE_NAME, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putInt("RANGE_MIN", min);
- editor.putInt("RANGE_MAX", max);
- editor.putBoolean("OPERATOR_ADD", add);
- editor.putBoolean("OPERATOR_SUB", sub);
- editor.putBoolean("OPERATOR_MULL", mul);
- editor.putBoolean("OPERATOR_DIV", div);
- editor.apply();
- }
- static void loadSettings(Context context) {
- SharedPreferences sharedPref = context.getSharedPreferences(PREFERENCE_FILE_NAME, Context.MODE_PRIVATE);
- min = sharedPref.getInt("RANGE_MIN", min);
- max = sharedPref.getInt("RANGE_MAX", max);
- add = sharedPref.getBoolean("OPERATOR_ADD", add);
- sub = sharedPref.getBoolean("OPERATOR_SUB", sub);
- mul = sharedPref.getBoolean("OPERATOR_MULL", mul);
- div = sharedPref.getBoolean("OPERATOR_DIV", div);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement