30 lines
907 B
Java
30 lines
907 B
Java
package com.ar.paintar.room;
|
|
|
|
import android.content.Context;
|
|
|
|
import androidx.room.Database;
|
|
import androidx.room.Room;
|
|
import androidx.room.RoomDatabase;
|
|
|
|
import com.ar.paintar.MyApplication;
|
|
|
|
@Database(entities = {ImageData.class}, version = MyApplication.Db_Version, exportSchema = false)
|
|
public abstract class AppDatabase extends RoomDatabase {
|
|
|
|
public abstract ImageDataDao imageDataDao();
|
|
private static volatile AppDatabase INSTANCE;
|
|
|
|
public static AppDatabase getInstance(Context context) {
|
|
if (INSTANCE == null) {
|
|
synchronized (AppDatabase.class) {
|
|
if (INSTANCE == null) {
|
|
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
|
|
AppDatabase.class, MyApplication.Db_Name)
|
|
.build();
|
|
}
|
|
}
|
|
}
|
|
return INSTANCE;
|
|
}
|
|
}
|