这是我的数据库,有人可以告诉我如何微调或自动更正mydatabase吗?
@Database(entities = {NotePelanggan.class}, version = 1)
public abstract class Pelanggandatabase extends RoomDatabase {
private static Pelanggandatabase instance;
public abstract PelangganDao pelangganDao();**strong text**
public static synchronized Pelanggandatabase getInstance(Context context) {
if (instance == null){
instance = Room.databaseBuilder(context.getApplicationContext(),
Pelanggandatabase.class, "pelanggan_database")
.fallbackToDestructiveMigration()
.addCallback(roomCallback)
.build();
}
return instance;
}
private static Callback roomCallback = new Callback(){
@Override
public void onCreate(@NonNull SupportSQLiteDatabase db) {
super.onCreate(db);
new PopulateDbAsyncTask(instance).execute();
}
};
private static class PopulateDbAsyncTask extends AsyncTask<Void, Void, Void> {
private PelangganDao pelangganDao;
private PopulateDbAsyncTask(Pelanggandatabase db){
pelangganDao = db.pelangganDao();
}
@Override
protected Void doInBackground(Void... voids) {
return null;
}
}
}