Reputation: 1
I am very new to Android Studio and I have a problem with DoaMaster Java Class. I have developed a simple app for getting user's input and store them, with an ability to send the stored data via message. I have the following error from android studio in DoaMaster Class, and it seems that the database type is wrong. (Required Type: Database, Provided: SQLite Database). This part of the codes has been used by another Class (AppDataBase.java, public static void initialize). What is the solution?
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1;
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
PlayerDao.createTable(db, ifNotExists);
SportDao.createTable(db, ifNotExists);
ExerciseDao.createTable(db, ifNotExists);
messageDao.createTable(db, ifNotExists);
}
public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
PlayerDao.dropTable(db, ifExists);
SportDao.dropTable(db, ifExists);
ExerciseDao.dropTable(db, ifExists);
messageDao.dropTable(db, ifExists);
}
public static abstract class OpenHelper extends SQLiteOpenHelper {
public OpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
super(context, name, factory, 1);
}
public void onCreate(SQLiteDatabase db) {
Log.i("greenDAO", "Creating tables for schema version 1");
DaoMaster.createAllTables(db, false);
}
}
public static class DevOpenHelper extends OpenHelper {
public DevOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
super(context, name, factory);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
DaoMaster.dropAllTables(db, true);
onCreate(db);
}
}
// Error is here
public DaoMaster(SQLiteDatabase db) {
super(db, 1);
registerDaoClass(PlayerDao.class);
registerDaoClass(SportDao.class);
registerDaoClass(ExerciseDao.class);
registerDaoClass(messageDao.class);
}
public DaoSession newSession() {
return new DaoSession(this.db, IdentityScopeType.Session, this.daoConfigMap);
}
public DaoSession newSession(IdentityScopeType type) {
return new DaoSession(this.db, type, this.daoConfigMap);
}
}
When I change the SQLite Database to Database, the Error disappeared, but the error is now in AppDataBase.java, public static void initialize!
Upvotes: 0
Views: 30