I’m trying to build an app with android using room as a database. While initializing the database I seem to have a problem using the databaseBuilder() method of room. I always get the error: can’t find symbol Room.databaseBuilder().
From my perspective it seems like the databaseBuilder doesn’t exist. I already tried to import androidx.room into my project but it still can’t find the method.
Is there a reason why it won’t find method databaseBuilder in class room or are there any alternatives?
This is my code:
import android.content.Context;
import androidx.room.Database;
import androidx.room.RoomDatabase;
@Database(entities = {Ente.class}, version = 1)
public abstract class DB extends RoomDatabase {
public abstract dao Dao();
private static DB _instance;
public synchronized static DB getInstance(final Context context){
if (_instance == null){
synchronized (DB.class){
if(_instance == null){
_instance = Room.databaseBuilder(context.getApplicationContext(),
DB.class,"Alle_Anzeigen");
}
}
}
return _instance;
}
}
adi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.