I have a remote database that contain data which loaded periodically to the Android app when a new version of data available - i.e. new data have been added or existed data been edited. I need to keep user preferences of data even if the data has been reloaded.
E.g. data is a collection of quotes, there is no user registration, user can favorite any quote he like. To speed up the app, data is stored in sqlite database.
Now when a new version available, the data will be reloaded, so what the best way to mark already favorited quotes (like favorited tweet), image below show the idea

I thought of adding an extra binary column to the local database for favorite/unfavorite. In addition store the ids of favorited qoutes in the device (SharedPreferences) When the updated data loaded, update the favorite column for qoutes that their ids stored in device with 1s, for the rest, the default value for favorite column is 0. This should be work but I think there may be a better solution. Any suggestion, Thanks!
Ok, I applied my suggestion above, test it and thanks God,it flawlessly works :].
Here the solution for anyone who is interested, it is not the optimal one though.
The design is slightly differ from above, when an item in the list been clicked, a new fragment will be created contain details of item and favorite, share, etc buttons So on click function
Inside My custom DatabaseHandler I add two functions [1] getFavoriteQuotesIds which returns favorited quotes ids as string seperated by "," to to be ready for IN clause inside update function: [2] restoreFavorite()
Now when update data loaded, the table of quotes will be dropped and recreated, the default value for favorite column is 0s for all quotes
So we need to restore favorite quotes, first, get the ids from sharedpreferences, Second call restoreFavorite function which will update the database
restoreFavorite function
What remain is the initial favorite button state for any qoute So, check for it inside OnViewCreated