Android: SharedPreferences not accessible from SyncAdapter

When I was trying to access a SharedPreferences value from my Android app’s SyncAdapter, I kept on receiving an old value that was saved to the key.

Quick solution to inaccessible SharedPreferences from SyncAdapter

A quick solution (which may be a short-term one) I tried was to remove android:process=":sync" from the following code:

But beware:

The attribute android:process=”:sync” tells the system to run the Service in a global shared process named sync. If you have multiple sync adapters in your app they can share this process, which reduces overhead.

My long-term solution to inaccessible SharedPreferences from SyncAdapter

Source:
SharedPreference committed in SyncAdapter not updated in Activity?

Catzie

A Filipino who is a mobile & web developer on weekdays, and a baker on weekends. When I have time to spare, I blog, play video games, watch series (usually anime), cook dishes, draw, or spend a little time with pets. When I have the rare luxury of time, I get to travel and record song covers too! Follow on Twitter: @catzie

Leave a Reply

Your email address will not be published. Required fields are marked *