A Pitfall on Android’s Shared Preferences


Recently, I got a strange bug report on one of our Android app. User’s favorite items are “removed” every time the app get killed. This issue really frustrated me since it took me a whole day without any clue on what’s going on. The favorites work well as expected until the app restarts, they’re gone — or in my phone, only one arbitrary favorite item left. Let’s see how I fixed it.

Continue reading