Change to Preferences in Android Backend

This message is brought to you by Nex, thanks mate!

In order to reduce overhead in the Android backend when putting values into Preferences, we’ve updated the implementation to not commit changes until flush() is called on the Preferences object. Previously, every time you put a value into Preferences the Android implementation would create an Editor, put the value, then commit it. While this was good for ensuring that values would be persisted quickly, it also meant File I/O for each and every value placed into preferences. When putting more than one or two values, this could create noticeable slowness.

This may sounds like a big deal, but this actually brings the Android implementation more in line with the other backends, which have always required flush() to be called in order to persist the changes. It also mirrors the normal workflow for working with SharedPreferences in normal Android development.

TL;DR Version: You must now call flush() in all cases where you want changes to Preferences to be persisted.

One thought on “Change to Preferences in Android Backend

  1. Nice. Now I don’t need to use an additional buffer while in-game (because changing a pref made the game hickup for a second).

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>