use apply for preferences instead of commit

Stops UI thread from blocking when the app decides to change a preference.
Cool, moved back to commit and added an assertion that the data was successfully written.