From 7f2bc01180c284154fb69976122016c4638e9973 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 7 Aug 2019 10:54:47 +0800 Subject: Preparing to support multi user. Use the database to store accounts' info. LoginActivity is successfully refactored. Any other features are unavailable for now. --- app/src/main/java/Account/AccountDao.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/src/main/java/Account/AccountDao.java (limited to 'app/src/main/java/Account/AccountDao.java') diff --git a/app/src/main/java/Account/AccountDao.java b/app/src/main/java/Account/AccountDao.java new file mode 100644 index 00000000..bd53b92b --- /dev/null +++ b/app/src/main/java/Account/AccountDao.java @@ -0,0 +1,22 @@ +package Account; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +@Dao +public interface AccountDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insert(Account account); + + @Query("DELETE FROM accounts") + void deleteAllAccounts(); + + @Query("SELECT * FROM accounts WHERE username = :userName COLLATE NOCASE LIMIT 1") + LiveData getAccountLiveData(String userName); + + @Query("SELECT * FROM accounts WHERE username = :userName COLLATE NOCASE LIMIT 1") + Account getAccountData(String userName); +} -- cgit v1.2.3