简体   繁体   中英

Android Internal storage VS Shared preferences

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

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

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

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... :/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM