PlayerPrefs.SetInt super slow on android?

i currently use PlayerPrefs.SetInt in my achievement tracking code.

on pc/mac/linux/ios it works without and problem but on android i get stutters whenever it is used. the maximum usage is twice per update so i don’t overdo it.

is that something others have experienced as well? or does anyone know the reason why it is so slow on android?

Memory access is slow on mobile devices but I’d never stored data twice per frame! Perhaps you should update PlayerPrefs only if there are any changes or at least only in fixed update.

You only use playerprefs when a button has been pressed in menus, or when there’s no real realtime stuff going on. It causes disc access which by large you avoid during gameplay. It is not slow.

You should store to a variable then save on pause, interruptions, quiet moments etc.

It’s overdoing it. Have to save to a variable instead, then just save later.

ok, i see your point :slight_smile:

i was just wondering cause on a 3rd gen ipod fromt he stone age it runs without any problem.

will change the code though, thanks for clearing it up!

Just to clarify where the speed difference is coming from; most Android phones work with cheap SDcard memory where Apple uses flash memory. Where the latter is way faster as you noticed.

yes, that’s what i assumed as well. good to keep that in mind for the future :slight_smile:

Well, is this really true? I’m getting SetInt suuuuper slow response time on Android as well. iOS? Blazing fast. I was under the impression SetInt was only setting a cached variable and that PlayerPrefs.Save() is what actually forced the write operation to disk. If this is true, then SetInt should not be slow at all…but it is. Take 20-30 SetInt calls in a row, it will pause my S4 for about 1-1.5 seconds. If this was truly cached, it would be no where near that slow. :frowning:

So I still feel like the Android version of PlayerPrefs is NOT caching like iOS and perhaps SetInt is writing to disk. :S