AccountManager getUserData returning null despite it being set

I am aware of one bug in Honeycomb plus that can cause your issue. If you try to getUserData of the account before it is registered all subsequent getUserData calls will return null.

If you look at the code. AccountManager has an in-memory cache that is backed by a sqlite database. Calling getUserData populates the in-memory cache userdata, even if it is not registered. If it is not registered it interprets that as no userdata. Registering an account only populates the database and does not invalidate the in-memory store.

This may be causing your issue.

The workaround is to remove the account before calling addAccountExplicitly.

Ya this issue sucks and is a HUGE bug in AccountManger IMO and allows third parties to essence DOS your app.


Are you using an HTC device with Android 4? I got many reports of this issue from users of my sync apps. All of them used an HTC device with SDK level 15.

Looks like an HTC bug to me.

Several users reported that issue vanished after a reboot.

Update: Meanwhile we found a proper workaround, see https://stackoverflow.com/a/29776224/1558654