1

我有一个问题:找不到只有辅助类的(上下文)参数的构造函数......

class ORMDBHelper extends OrmLiteSqliteOpenHelper {
    private EventDAO mMyDao;

    public ORMDBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
        try {
            TableUtils.createTable(connectionSource, MyClass.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource,
            int oldVersion, int newVersion) {
        try {
            TableUtils.dropTable(connectionSource, MyClass.class, true);
            onCreate(db, connectionSource);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public EventDAO getEventDAO() throws SQLException {
        if (mMyDao == null) {
            mMyDao = new MyDAO(getConnectionSource(), MyClass.class);
        }

        return mMyDao;
    }

    public void clearTable(Class dataClass) throws SQLException {
        TableUtils.clearTable(getConnectionSource(), dataClass);
    }

    @Override
    public void close() {
        super.close();

        mMyDao = null;
    }
}

错误所在的行:

mDbHelper = OpenHelperManager.getHelper(context, ORMDBHelper.class);

我找到了一些答案,但它们是混淆的解决方案。

4

1 回答 1

1

找不到只有辅助类的(上下文)参数的构造函数...

确保ORMDBHelper类是public因为否则类和构造函数将不可见。

否则它可能指的是不同的ORMDBHelper类,或者Context参数可能是错误的类型?

于 2013-05-31T13:40:31.210 回答