Skip to content

Instantly share code, notes, and snippets.

@amit-bhandari
Created April 14, 2019 15:04
Show Gist options
  • Save amit-bhandari/b84837b44fade5424df0772555a00e7c to your computer and use it in GitHub Desktop.
Save amit-bhandari/b84837b44fade5424df0772555a00e7c to your computer and use it in GitHub Desktop.
@Dao
public interface QuoteDAO {
@Insert(onConflict = REPLACE)
void cacheOnDB(List<Quote> quote);
@Query("SELECT * FROM quote")
LiveData<List<Quote>>getCachedQuotes();
//for saved quotes (starred quotes)
@Insert(onConflict = REPLACE)
void saveOnDevice(SavedQuote quote);
//no need of live data, we won’t be making any changes to it
@Query("SELECT * FROM savedquote")
List<SavedQuote> getSavedQuotes();
@Delete
void deleteQuote(SavedQuote quote);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment