LastPipeBender/app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java

35 lines
938 B
Java
Raw Normal View History

package org.schabi.newpipe;
import android.arch.persistence.room.Room;
import android.content.Context;
import android.support.annotation.NonNull;
import org.schabi.newpipe.database.AppDatabase;
import static org.schabi.newpipe.database.AppDatabase.DATABASE_NAME;
public class NewPipeDatabase {
private static AppDatabase sInstance;
// For Singleton instantiation
private static final Object LOCK = new Object();
@NonNull
public synchronized static AppDatabase getInstance(Context context) {
if (sInstance == null) {
synchronized (LOCK) {
if (sInstance == null) {
sInstance = Room.databaseBuilder(
context.getApplicationContext(),
AppDatabase.class,
DATABASE_NAME
).build();
}
}
}
return sInstance;
}
}