Is there any way to get Cursor for a query, which I am processing with ORMLite Dao object?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ORMLite now supports
next(),previous(),moveRelative(offset), … methods on theCloseableIteratorclass. This should allow you to move the underlyingCursorobject around at will.It also supports the following DAO Cursor methods:
dao.mapSelectStarRow(databaseResults)Return the latest row from the database results from a query toselect *. With this you can change the cursor location (for example) and then get the current object.dao.getSelectStarRowMapper()Provides a mapper that you can use to map the object outside of the Dao.When you are building your own query with ORMLite, you use the
QueryBuilderobject.queryBuilder.prepare()returns aPreparedQuerywhich is used by various methods in the DAO. You can calldao.iterator(preparedQuery)which will return aCloseableIteratorwhich is used to iterate through the results. There is aiterator.getRawResults()to get access to theDatabaseResultsclass. Under Android, this can be cast to anAndroidDatabaseResultswhich has agetCursor()method on it to return the AndroidCursor.Something like the following code:
This is a bit complicated but you are definitely having to peer behind the vale to get to this object which is hidden by the database abstraction classes.