小编Wra*_*ous的帖子

何时调用 editor.apply?

在我的应用程序中,我最多可以由用户定义 20 个假期,当将它们保存到共享首选项编辑器时,我将其设置如下:

String checkhold = "0";
String holodate = g.getData82();// string is either "0" if no holidays entered, or, for example, "1,1,7,4,12,25, if January 1st, July 4th and December 25th is entered

if (!holodate.equals("0")) {

    checkhold = holodate;
    int value = 0;
    String splitHere = "[,]";
    String[] sToken = holodate.split(splitHere);
    int count = holodate.length() - checkhold.replace(",", "").length();
    g.setData92(emp, count);
    double holidayNumber = count * 0.5;
    passeditor.putDouble(holnums, holidayNumber);

if (count >= 0) {
    value = Integer.parseInt(sToken[0]);
    g.setData90(0, value);
    passeditor.putInt(holmonth1, value);passeditor.apply(); …
Run Code Online (Sandbox Code Playgroud)

java android sharedpreferences

1
推荐指数
1
解决办法
124
查看次数

标签 统计

android ×1

java ×1

sharedpreferences ×1