shanehoban
shanehoban

Reputation: 870

Does Committing Editor - SharedPreferences Close the Transaction?

I am going to have three 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

Can I just keep calling editor = *.edit(); as long as I commit the changes to the SharedPreferences?

Thanks in advance

Upvotes: 0

Views: 279

Answers (1)

kabuko
kabuko

Reputation: 36302

Yes. All you need to do to complete your transaction is call commit as you already are.

Upvotes: 1

Related Questions