list - Using limit () and offset () in QueryBuilder (ANDROID , ORMLITE) -
@suppresswarnings("deprecation") public list<picture> returnlimitedlist(int offset, int end) { list<picture> picturelist = new arraylist<picture>(); int startrow = offset; int maxrows = end; try { querybuilder<picture, integer> querybuilder = dao.querybuilder(); querybuilder.offset(startrow).limit(maxrows); picturelist = dao.query(querybuilder.prepare()); } catch (sqlexception e) { e.printstacktrace(); } return picturelist; }
- i have table of pictures in database, , must return limited list, 20 lines @ time.
- but when use ex: querybuilder.offset(11).limit(30);
- i can not return list limited 20 lines.
- the list comes me limit.
- it's if offset remain value 0
ex: (0 - 30)
is there other way return limited list initial index , end index?
- could me?
this question asked 2 months ago, i'll answer if stumbled on same problem did.
there's misunderstanding offset
means in case, here follows sqlite documentations says it
if expression has offset clause, first m rows omitted result set returned select statement , next n rows returned, m , n values offset , limit clauses evaluate to, respectively.
based on query, you'll return 30 lines starting @ #11 line.
so correct way is:
querybuilder.offset(startrow).limit(20);
with limit
being number of rows return, not ending row.
picturelist = dao.query(querybuilder.prepare());
and returned list
first value starting on picturelist.get(0)
edit: @gray 's on comments
Comments
Post a Comment