Created
November 3, 2018 09:38
-
-
Save ajaypro/eafc6b5c320536f4ab279eaad9f62bed to your computer and use it in GitHub Desktop.
Roomdatabase subclass
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
@Database(entities = {objects.ChecklistItem.class, OfflineData.class}, version = 4, exportSchema = false) | |
@TypeConverters({DateConverter.class, GeopointsConverter.class}) | |
public abstract class DbChecklist extends RoomDatabase { | |
private static final Object LOCK = new Object(); | |
private static final String DATABASE_NAME = "****.db"; | |
private static DbChecklist sInstance; | |
public static DbChecklist getsInstance(Context context) { | |
//to make sure that Singleton Pattern is followed | |
//i.e. only one object of the class is created. | |
if (sInstance == null) { | |
synchronized (LOCK) { | |
sInstance = Room.databaseBuilder(context.getApplicationContext(), | |
DbChecklist.class, DbChecklist.DATABASE_NAME) | |
.addMigrations(MIGRATION_3_4) | |
.build(); | |
} | |
} | |
return sInstance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment