Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the best way to store data such as 'Favorites' on an Android-app?

Tags:

android

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?

like image 860
Zeno Avatar asked Aug 24 '10 13:08

Zeno


People also ask

What are the ways to store data in Android?

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.

How many ways are there to store data by Android application?

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.

Which techniques can be used to persist data in a mobile app?

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.


2 Answers

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.

like image 195
BenTobin Avatar answered Oct 20 '22 21:10

BenTobin


If you know SQL go with SQLite database if you don't maybe go with SharedPreferences.

like image 37
Pentium10 Avatar answered Oct 20 '22 23:10

Pentium10