如何使用ActiveAndroid查询结果只能获得一列?

jul*_*jul 4 android activeandroid

如何才能获得仅包含Category模型"Name"列的数组?

我可以使用我的所有类别

List<Category> categoryList = new Select()
    .from(Category.class)
    .execute();
Run Code Online (Sandbox Code Playgroud)

然后创建另一个名为的数组Category,但我想有一种方法直接得到它,我找不到如何.

sjw*_*odr 12

回答这个问题有点晚了,但问题是因为SQLiteUtils.rawQuery()假设Id列总是在游标结果中.将列String []设置为{Id,your_column},你会没事的.

    List<Category> categoryList = new Select(new String[]{"Id,your_column"}).from(Category.class).execute();
Run Code Online (Sandbox Code Playgroud)