我将 GreenDao 用于我的 Android 项目。但是有个小问题!我无法启动我的应用程序,因为我的数据库连接出现了一些故障
错误:
Could not find Class "...\DaoMaster" referenced form method "...\onCreate
我找不到解决方案,有人说,这取决于我的 DevOpenHelper 语句中的“this”。但所有这些解决方案都无济于事。
这是代码:
public class MainActivity extends Activity {
//db helper and dao
private SQLiteDatabase db;
private DaoMaster daoMaster;
private DaoSession daoSession;
private NoteDao noteDao;
private Cursor cursor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//set up database
DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db", null);
db = helper.getWritableDatabase();
daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
noteDao = daoSession.getNoteDao();
}
}