apptentive / apptentive-android

Apptentive Android SDK
http://www.apptentive.com
BSD 3-Clause "New" or "Revised" License
65 stars 64 forks source link

Use apply() instead of commit() when using SharedPreferences.Editor #118

Closed solcott closed 8 years ago

solcott commented 8 years ago

I noticed that when you are editing SharedPreferences you are using commit() In our tests commit takes about 10 milliseconds to write the changes to disk. You should probably use apply() instead of commit(). apply() writes the changes to disk asynchronously. The javadoc for commit() states the following:

If you don't care about the return value and you're using this from your application's main thread, consider using apply() instead.

skykelsey commented 8 years ago

Thanks Scott. We're planning on purging all the unnecessary synchronous commits in our next release. Thanks for bringing this to our attention.

skykelsey commented 8 years ago

This is implemented in 3.0.0. Enjoy!