java.lang.IllegalStateException:找不到OpenHelperClass?

时间:2013-08-12 11:50:30

标签: android sqlite ormlite

我正在使用带有sqlite的ormlite。但我们得到的错误就像

java.lang.IllegalStateException: Could not find OpenHelperClass because none of the generic parameters of class class comactivty.ActivityName extends OrmLiteSqliteOpenHelper.  You should use getHelper(Context, Class) instead.

我的代码是:

public class DatabaseManager<H extends OrmLiteSqliteOpenHelper> {

    private H helper;
    public H getHelper(Context context)
    {
        if(helper == null)
        {
            helper = (H) OpenHelperManager.getHelper(context);
        }
        return helper;
    }

    public void releaseHelper(H helper)
    {
        if (helper != null) {
            OpenHelperManager.release();
            helper = null;
        }
    }

}

这种方法getHelper(context);现已弃用,因此错误说使用此getHelper(Context, Class)。那么如何使用它。

1 个答案:

答案 0 :(得分:0)

如错误消息所示,请使用方法:getHelper(Context, DatabaseManager.class);