我正在创建一个具有多个警报的警报应用程序..所以我想将时间存储在共享首选项中。如果有任何解决方案来存储共享首选项中的整数列表
答案 0 :(得分:1)
SharedPreferences preferences = getSharedPreferences("prefs", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("key", yourIntValue);
editor.apply();
使用editor.apply()
异步保存首选项。在大多数情况下,apply()
更为可取。
使用editor.commit()
同步保存偏好设置。