aboutsummaryrefslogblamecommitdiff
path: root/app/src/main/java/Account/AccountRoomDatabase.java
blob: 2f5d0120ff1ac1ac3ad69b08a07c6abff8ebe0bc (plain) (tree)


























                                                                                    
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;
    }
}