Preparing to support multi user. Use the database to store accounts' info. LoginActivity is successfully refactored. Any other features are unavailable for now.

This commit is contained in:
Alex Ning
2019-08-07 10:54:47 +08:00
parent 77d83654aa
commit 7f2bc01180
10 changed files with 357 additions and 20 deletions

View File

@ -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<Account> getAccountLiveData(String userName);
@Query("SELECT * FROM accounts WHERE username = :userName COLLATE NOCASE LIMIT 1")
Account getAccountData(String userName);
}