mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-05 05:20:44 +03:00
35 lines
938 B
Java
35 lines
938 B
Java
|
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;
|
||
|
}
|
||
|
}
|