Android App , add a favorite quote functionality

617 Views Asked by At

I have an android app which displays quotes and have navigation to go to next quote and so on. would like to add "Save Quote As favourite" based on users selection of particular quote.

Once user saves Fav quotes and wants to see those quotes only, app should show those quotes.

Currently app reads the quotes from XML file. Let me know if any more information is required to understand the problem.

1

There are 1 best solutions below

0
On

I would provide every quote with an ID (int). Whenever the user selects a quote to be a favourite, that ID is saved to a Set of integers. Later on if user decides to show favourites, you fetch all quotes with your IDs from the Set and show them in a appropriate view, for example a ListView

If you have a Quote class or something like that, you might as well put them in a collection whenever user decide his favourites, and show them in a ListView with a custom adapter.