Last active
July 16, 2019 10:13
-
-
Save ankitdubey021/39b91ad53df38cb5342a3c46cdfa79e8 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 dao; | |
import android.content.Context; | |
import androidx.room.Database; | |
import androidx.room.Room; | |
import androidx.room.RoomDatabase; | |
@Database(entities = {Student.class},version = 1, exportSchema = false) | |
public abstract class AppDatabase extends RoomDatabase { | |
private static final String DATABASE_NAME="student_db"; | |
private static final Object LOCK=new Object(); | |
private static AppDatabase instance; | |
public static AppDatabase getInstance(Context context){ | |
if (instance==null){ | |
synchronized (LOCK) { | |
instance = Room.databaseBuilder( | |
context.getApplicationContext(), | |
AppDatabase.class, | |
AppDatabase.DATABASE_NAME).build(); | |
} | |
} | |
return instance; | |
} | |
public abstract StudentDAO getStudentDao(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment