1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package androidx.work.integration.testapp.db; 17 18 import android.arch.lifecycle.LiveData; 19 import android.arch.persistence.room.Dao; 20 import android.arch.persistence.room.Insert; 21 import android.arch.persistence.room.Query; 22 23 import java.util.List; 24 25 /** 26 * The Data Access Object for {@link WordCount}. 27 */ 28 @Dao 29 public interface WordCountDao { 30 31 /** 32 * Inserts a {@link WordCount} into the database. 33 * 34 * @param wordCount The {@link WordCount} to insert 35 */ 36 @Insert 37 void insertWordCount(WordCount wordCount); 38 39 /** 40 * Gets all {@link WordCount}s in the database. 41 * 42 * @return A {@link LiveData} list of all {@link WordCount}s in the database 43 */ 44 @Query("SELECT * FROM wordcount") 45 LiveData<List<WordCount>> getWordCounts(); 46 47 /** 48 * Clears the database. 49 */ 50 @Query("DELETE FROM wordcount") 51 void clear(); 52 } 53