I know the difference between apply and commit.
In my case I would like to use commit()
, but android suggests me to use apply()
because it runs in background and doesn't block the main thread.
Does something like this work if I use apply or is it possible that apply did not update it before calling?
editor.putBoolean("TEST", true)
editor.apply()
if (preferences.getBoolean("TEST")) {
//do something
}