Android ORMLite 获取表达式预期错误

Android ORMLite get expression expected error

我正在阅读 OrmLite 文档,我正在尝试创建 DatabaseHelper extends from OrmLiteSqliteOpenHelper。导入库并创建 class 后,我在这段代码中得到 ConnectionSourceexpression expected error

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

    }
}

这是什么问题,如何解决?我创建的完整 class 是:

public class DatabaseHelper extends OrmLiteSqliteOpenHelper {

    private static final String DATABASE_NAME = "eitaa_database.db";
    private static final String DATABASE_VERSION = "1";

    public DatabaseHelper(Context context){
        super(context, DATABASE_NAME, null, DATABASE_VERSION, R.raw.ormlite_config);
    }

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

        }
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase,
                          ConnectionSource connectionSource,
                          int old_version, int new_version) {
        try{
            TableUtils.dropTable(ConnectionSource, Categories.class);
        }catch (SQLException e){

        }
    }
}

我的 Categories.java class 是:

@DatabaseTable(tableName = "table_category")
public class Categories {

    @DatabaseField(generatedId = true)
    public int id;

    @DatabaseField
    public String subject;

    public Categories() {
    }

    public Categories(int id, String subject, String text, Date date) {
        super();
        this.id = id;
        this.subject = subject;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    @Override
    public String toString() {
        return "Categories{" +
                "  id=" + id +
                ", subject='" + subject + '\'' +
                '}';
    }
}

在这一行中:TableUtils.createTable(ConnectionSource, Categories.class); 你必须使用变量名。不是类名:

 TableUtils.createTable(connectionSource, Categories.class);

见小写c