aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/Account/AccountRoomDatabase.java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-07 02:54:47 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-07 02:54:47 +0000
commit7f2bc01180c284154fb69976122016c4638e9973 (patch)
treeb009b9cfab924cce98c25ae5b6355af4f18c311c /app/src/main/java/Account/AccountRoomDatabase.java
parent77d83654aa8063b0c4d9f95ba91bd3d77be84ad9 (diff)
downloadinfinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar
infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.gz
infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.bz2
infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.lz
infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.xz
infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.zst
infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.zip
Preparing to support multi user. Use the database to store accounts' info. LoginActivity is successfully refactored. Any other features are unavailable for now.
Diffstat (limited to 'app/src/main/java/Account/AccountRoomDatabase.java')
-rw-r--r--app/src/main/java/Account/AccountRoomDatabase.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/src/main/java/Account/AccountRoomDatabase.java b/app/src/main/java/Account/AccountRoomDatabase.java
new file mode 100644
index 00000000..2f5d0120
--- /dev/null
+++ b/app/src/main/java/Account/AccountRoomDatabase.java
@@ -0,0 +1,27 @@
+package Account;
+
+import android.content.Context;
+
+import androidx.room.Database;
+import androidx.room.Room;
+import androidx.room.RoomDatabase;
+
+@Database(entities = {Account.class}, version = 1)
+public abstract class AccountRoomDatabase extends RoomDatabase {
+ private static AccountRoomDatabase INSTANCE;
+
+ public abstract AccountDao accountDao();
+
+ public static AccountRoomDatabase getDatabase(final Context context) {
+ if(INSTANCE == null) {
+ synchronized (AccountRoomDatabase.class) {
+ if(INSTANCE == null) {
+ INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
+ AccountRoomDatabase.class, "accounts")
+ .build();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+}