Android Internal storage VS Shared preferences

丶灬走出姿态 提交于 2019-12-21 10:12:30

问题


Is there a difference between storing service authentication token in Internal storage (in file) and in Shared Preferences?


回答1:


Not really, it's a matter of convenience. With shared preferences you don't need to handle file IO.




回答2:


shared preference will be better than to store credential in file, to open and readfile is tedious compare to use of share preference




回答3:


Although both can be private types. The conventional approach is: if you have small key value pair go with shared preference. If you have large chunk of data go with Internal storage. Internal storage stores in files and is private to your application. The major drawback with shared pref. is if your app crashes/ force close you lose all your data in shared pref.

Verdict:

If you use shared pref. make sure your app doesn't crash. So my point of view: go with internal storage. Nevertheless, if your phone is rooted ANYTHING can happen, nothing remains private anymore... :/



来源:https://stackoverflow.com/questions/7076304/android-internal-storage-vs-shared-preferences

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!