---
updatedAt: 2026-02-12T13:35:59.000Z
agentTools:
  projectIndex: https://docs.emergetools.com/llms.txt
---

# Shared Preferences commit() calls (Android)

Shared Preferences **[commit()](https://developer.android.com/reference/android/content/SharedPreferences.Editor#commit\(\))** is synchronous, you should avoid calling it from your main thread because it could pause your UI rendering.

As a replacement, you can use **[apply()](https://developer.android.com/reference/android/content/SharedPreferences.Editor#apply\(\))** which changes the in-memory **[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences)** object immediately but writes the updates to disk asynchronously.

![900](https://files.readme.io/7c76af4-Screen_Shot_2022-08-25_at_16.02.43.png "Screen Shot 2022-08-25 at 16.02.43.png")