Domanda

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);
È stato utile?

Soluzione

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top