Last active
September 22, 2019 11:52
-
-
Save zainfikrih/de4993c1a28661ea3716930950a760d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package men.ngopi.zain.catatanku.local.room; | |
import android.content.Context; | |
import androidx.room.Database; | |
import androidx.room.Room; | |
import androidx.room.RoomDatabase; | |
import men.ngopi.zain.catatanku.local.entity.NoteEntity; | |
@Database(entities = {NoteEntity.class}, version = 1, exportSchema = false) | |
public abstract class CatatankuDatabase extends RoomDatabase { | |
public abstract CatatankuDao catatankuDao(); | |
private static volatile CatatankuDatabase INSTANCE; | |
public static CatatankuDatabase getDatabase(final Context context) { | |
if (INSTANCE == null) { | |
synchronized (CatatankuDatabase.class) { | |
if (INSTANCE == null) { | |
INSTANCE = Room.databaseBuilder( | |
context.getApplicationContext(), | |
CatatankuDatabase.class, "catatanku_database") | |
.build(); | |
} | |
} | |
} | |
return INSTANCE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment