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?
Android provides many kinds of storage for applications to store their data. These storage places are shared preferences, internal and external storage, SQLite storage, and storage via network connection.
The Android platform provides developers with multiple ways to store data, with each method having it's advantages and disadvantages. Ways to store data :There are basically four different ways to store data in an Android app: Shared Preferences.
For Android, there are primarily three basic ways of persisting data: A lightweight mechanism known as shared preferences to save small chunks of data. Traditional file systems. A relational database management system through the support of SQLite databases.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With