Add to Favorite Function using Shared Preferences Android

527 views Asked by At

I wanted to create an add favorite function for my item in a list view. But i have no idea which approach i should use, either shared preferences or sqlite DB. Can any one give opinion regarding this?

Thanks

1

There are 1 answers

1
Damian Kozlak On

If you want to hold small data, like ID's or something, you should use SharedPreferences - they're fast and easy to use. Keep it as String with ex. comma as separator or just use Set.

If you want to hold big amount of structured, organized, data, keeping whole object, it would be better to use SQLite database. This is more complicated.

Remember both options are read/write operations, so they must not be done on main thread.