I have the following models

categories(id, name)
places(id, name, category_id)

i have a list view which displays Content based on the categories the user wants to see.

Data for Categories

1, River
2, Hill Station
3, Wild Life
4, Temples

If the user wants to see places of only category_id = 2 and 4.

How can i do a query to the database to give back a list of places which have category_id = 2 and 4.

I am using stORM library for the Database.

They have the following functions to do a query.

dao.listAll();
dao.listByExample(exampleObj);
有帮助吗?

解决方案

If you switch to greenDAO, you can use a QueryBuilder, which supports IN and the likes: http://greendao-orm.com/documentation/queries/

其他提示

I use ormlite for this purpose. Check out section in the docs about the query-builder.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top