From 07fd2f2f477e7fe3a21512ebc0f55bf23c8d4ceb Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 2 May 2021 22:38:15 -0600 Subject: kindof understand mvvm --- .../wiimmterfaceandroid/database/AppDatabase.java | 11 ++++++++ .../database/FriendCodeDao.java | 30 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java create mode 100644 app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java (limited to 'app/src/main/java/com/example/wiimmterfaceandroid/database') diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java b/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java new file mode 100644 index 0000000..0f01149 --- /dev/null +++ b/app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java @@ -0,0 +1,11 @@ +package com.example.wiimmterfaceandroid.database; + +import androidx.room.Database; +import androidx.room.RoomDatabase; + +import com.example.wiimmterfaceandroid.model.FriendCode; + +@Database(entities = {FriendCode.class}, version=1) +public abstract class AppDatabase extends RoomDatabase { + public abstract FriendCodeDao getFriendCodeDao(); +} diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java b/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java new file mode 100644 index 0000000..e9762fd --- /dev/null +++ b/app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java @@ -0,0 +1,30 @@ +package com.example.wiimmterfaceandroid.database; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import com.example.wiimmterfaceandroid.model.FriendCode; + +import java.util.List; + +@Dao +public interface FriendCodeDao { + + @Query("SELECT * FROM friendcode") + public List getAll(); + + @Query("SELECT * FROM friendcode") + public FriendCode findByCode(String friendCode); + + @Insert + public void insert(FriendCode friendCode); + + @Update + public void update(FriendCode friendCode); + + @Delete + public void delete(FriendCode friendCode); +} -- cgit v1.2.3