diff options
Diffstat (limited to 'app/src/main/java/com/example/wiimmterfaceandroid/database')
-rw-r--r-- | app/src/main/java/com/example/wiimmterfaceandroid/database/AppDatabase.java | 11 | ||||
-rw-r--r-- | app/src/main/java/com/example/wiimmterfaceandroid/database/FriendCodeDao.java | 30 |
2 files changed, 41 insertions, 0 deletions
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<FriendCode> 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); +} |