what is the best way to store data such as 'Favorites' on an Android-app?
I am developing an Android application where you should be able to browse restaurants.
Im retrieving 开发者_开发知识库the information about the restaurants from a service, they are not stored locally on the device. But I want to allow the user to add a restaurant to his/her favorites.
What is the "best" way to store that kind of info on the device? Should I use Shared Preferences or Sqlite db? Or any other suggestions?
SqLite is probably the best way to go. It will allow you to structure the information in useful ways, whereas SharedPreferences is more of a Key-Value affair. That might be fine if you only need to store a set of strings, but it will be a pain if you ever decide you need to store additional information with a favorite, such as ordering, type, or date.
If you use SqLite, you can easily add columns.
If you know SQL go with SQLite database if you don't maybe go with SharedPreferences.
For now Room is best as it is easy as compared to Sqlite Database and its layer over sqlite database so you don't need to remember the queries and use room.
精彩评论