Last active
July 18, 2020 11:18
-
-
Save codejunk1e/8346aa354ce898702547391e0a2222c9 to your computer and use it in GitHub Desktop.
Room Dao File template Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.lifecycle.LiveData; | |
import androidx.room.Dao; | |
import androidx.room.Delete; | |
import androidx.room.Insert; | |
import androidx.room.OnConflictStrategy; | |
import androidx.room.Query; | |
import androidx.room.Update; | |
import java.util.List; | |
@Dao | |
public interface ${INTERFACE_NAME} { | |
@Query("SELECT * FROM [tableName] ORDER BY [id]") | |
LiveData<List<${MODEL_NAME}>> loadAll${MODEL_NAME}s(); | |
@Insert | |
void insert${MODEL_NAME}(${MODEL_NAME} placeholder); | |
@Update(onConflict = OnConflictStrategy.REPLACE) | |
void update${MODEL_NAME}(${MODEL_NAME} placeholder); | |
@Delete | |
void delete${MODEL_NAME}(${MODEL_NAME} placeholder); | |
@Query("SELECT * FROM [tableName] WHERE [id] = :id") | |
LiveData<${MODEL_NAME}> load${MODEL_NAME}ById(int id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment