Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get only one column as the result of a query with ActiveAndroid?

How can I get an array with only the column "Name" of my Category model?

I can get all my categories using

List<Category> categoryList = new Select()
    .from(Category.class)
    .execute();

and then create another array with the name of the Category, but I guess there is a way to get it directly and I cannot find how.

like image 385
jul Avatar asked Dec 14 '22 20:12

jul


1 Answers

A little late in answering this, but the issue is because SQLiteUtils.rawQuery() makes the assumption that the Id column is always going to be in the cursor result. Set your columns String[] to {Id, your_column} and you'll be fine.

List<Category> categoryList = new Select(new String[]{"Id,your_column"}).from(Category.class).execute();
like image 145
sjwoodr Avatar answered Dec 28 '22 23:12

sjwoodr