是否提交编辑器 - SharedPreferences关闭事务?

时间:2014-04-09 18:12:08

标签: android sharedpreferences android-preferences

我将有三个SharedPreferences:

 
private SharedPreferences cakes, tarts, pies;
private SharedPreferences.Editor editor;
....

cakes = getSharedPreferences("cakes", MODE_PRIVATE);
tarts = getSharedPreferences("tarts", MODE_PRIVATE);
pies = getSharedPreferences("pies", MODE_PRIVATE);
....

editor = cakes.edit();
editor.putLong("date", Shane.getTime());
editor.commit(); // <--- does this let me use editor again, like so:

editor = tarts.edit();
editor.putLong("date", Shane.getTime());
editor.commit();

...and so on

只要我将更改提交给SharedPreferences,我可以继续调用editor = *.edit();吗?

提前致谢

1 个答案:

答案 0 :(得分:1)

是。您完成交易所需要做的就是调用commit