Почему мой sharedpreferences.editor вылетает?

static SharedPreferences saver;
static SharedPreferences.Editor edit;
final static String[][] APP_SHOP = {{"figure1", "figure1", "figure1", "figure1"}, {"SHOP2"}, {"SHOP3"}, {"SHOP4"}};

static int[][] shop_items = new int[4][1];

то что сохраняю

public static void save() {
    edit = saver.edit();
    edit.putInt(APP_STATE, Integer.parseInt(score.getText().toString()));
    edit.putBoolean(APP_MUSIC, sound);
    edit.apply();
}

sharedpreferences.editor

case R.id.buyFl:
                buy(150, imgFl, buyFl, priceFl);
                GameScreen.shop_items[1][0] = 1;
                GameScreen.edit.putInt(GameScreen.APP_SHOP[1][0], GameScreen.shop_items[1][0]);
                GameScreen.edit.apply();
                break;

то что вылетает

ошибка:јava.lang.NullPointerException: Attempt to invoke interface method 'android.content.SharedPreferences$Editor androi d.content.SharedPreferences$Editor.putlint(java.lang.String, int)' on a null object referencе


Ответы (1 шт):

Автор решения: EnGold

Массив с переменными пустой, следует сделать так:

int[][] shop_items= {{0,0,0,0},{0},{0},{0}};

так потому что именно столько значений мне нужно

→ Ссылка