当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Shared preferences gets wiped out, when do you use it then?

问题描述:

I always try to avoid using shared preferences for storage in my app for the followinng reasons:

  • It gets wiped out on device reboot
  • It gets wiped out when cache data is cleared
  • It gets wiped out on force exit (through task manager)

Which makes me to always resort to internal storage (I/O). However, I see that many people in SO use shared preferences or recommend shared preferences for each other. Am I missing the point here? In particular, when do you use Shared PReferences?

Thanks you

网友答案:

It makes a lot of sense for simple things like settings/preferences, and checking whether or not to show an introduction. I use it in conjunction with syncing to a server. It is also good to allow the user to clear data associated with your app without going into the file system.

Also, SharedPreferences shouldn't be getting wiped when a device reboots or force closes.

网友答案:

SharedPreference works like a DB but in a small scale:SharedPreference

分享给朋友:
您可能感兴趣的文章:
随机阅读: