문제

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