New programmer here trying to self-learn, apologies for any stupid questions.
I'm trying to build a SQLite database with a singleton pattern in Android, so I can access the same DB through many different activities. I have the code below, but in the dbInstance = DatabaseHelper(context.getApplicationContext());
line, they have flagged an error "Method call expected".
I've searched google and this site, but it seems like this error can be triggered for a variety of reasons, and I wasn't able to figure out what's wrong in my case.
private static class DatabaseHelper extends SQLiteOpenHelper{
private static DatabaseHelper dbInstance = null;
private DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public static DatabaseHelper getInstance(Context context) {
synchronized(DatabaseHelper.class) {
if(dbInstance == null) {
dbInstance = DatabaseHelper(context.getApplicationContext());
}
}
return dbInstance;
}
Appreciate all of your help in advance!