我有两个修改共享首选项文件的 onclick 操作:
int value = counters.getInt("wcounter", 0);
wcounter = value;
wcounter++;
Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();
和
int value = counters.getInt("wcounter", 0);
wcounter = value;
wcounter--;
Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();
但是当第一个被重新执行时,它会采用它的旧值。