~/talk

The Dangers of SharedPreferences: An API allegory

Talkat droidcon San Francisco 2018 · 2018-11-19..11-20· [api-design, android]
links:none on file

SharedPreferences’ default apply has no callback, so writes go to an in‑memory map and an async OS threadpool (CuedWork) and can silently fail when flash is full or flaky; commit returns a boolean so you can detect disk failures but most apps ignore it. Investigation uses Android xref to inspect SharedPreferencesImpl, AtomicFile and backup behavior. Mobile flash failures are non‑negligible across millions of devices, so teams replace SharedPreferences or add a callback to make writes observable.

AI-written summary · about

  1. 0:00Introduction
  2. 1:55OS API design challenges
  3. 10:11Key-value storage options
  4. 14:21SharedPreferences overview
  5. 21:24Why flash writes fail
  6. 23:32Apply vs commit behavior
  7. 27:11Source code deep dive
  8. 33:21API contract flaws
  9. 34:47When to use SharedPreferences
  10. 36:55Alternatives and fixes
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.