Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:32:22+00:00 2026-06-15T23:32:22+00:00

I am trying to retrieve a Cursor from a ORMLite PreparedQuery. My goal is

  • 0

I am trying to retrieve a Cursor from a ORMLite PreparedQuery.
My goal is to only paginate my results query, so the device memory won’t be too overloaded.
I’ve read Gray’s guides on how to use the QueryBuilder object Android Cursor with ORMLite to use in CursorAdapter.
Also this one ORMLite with CursorAdapter in Android.
But when I try to do: “iterator.getRawResults();” well, the iterator class don’t recognize the getRawResults method. It just supports the common methods close(), getEquals(), next(), and so on…

I can retrieve e list of objects successfully from my query, so it isn’t a empty query problem…

am I missing something ?
My pom.xml is attached.

Here is the test with a list of Objects

public List<Produto> getProdutoDecricao2(String padrao) throws SQLException {

    List<Produto> listaProduto = null;
    QueryBuilder<Produto, String> queryBuilder = produtoDao.queryBuilder();
    Where<Produto, String> where = queryBuilder.where();
    SelectArg selectArg = new SelectArg();
    selectArg.setValue('%'+padrao+'%');
    where.like("descricao", selectArg);

    PreparedQuery<Produto> preparedQuery = queryBuilder.prepare();      
    listaProduto = produtoDao.query(preparedQuery);

    return listaProduto;

}

My failed attempt with Cursors…

//creation of DAO
private Dao<Produto,String> produtoDao;

public Cursor getProdutoDecricao(String padrao)  {
    List<Produto> listaProduto = null;
    QueryBuilder<Produto, String> queryBuilder = produtoDao.queryBuilder();
    Where<Produto, String> where = queryBuilder.where();
    SelectArg selectArg = new SelectArg();
    selectArg.setValue('%'+padrao+'%');
    where.like("descricao", selectArg);

// when you are done, prepare your query and build an iterator
    PreparedQuery<Produto> preparedQuery =  queryBuilder.prepare();
    CloseableIterator<Produto> iterator = produtoDao.iterator(preparedQuery);

    AndroidDatabaseResults results = (AndroidDatabaseResults)iterator.getRawResults();
    Cursor cursor = results.getRawCursor();

    iterator.close();


    return cursor;

    }

Here is the project pom.xml

<properties>
    <android-platform>8</android-platform>
    <android-maven-plugin-version>3.4.0</android-maven-plugin-version>
    <maven-compiler-plugin-version>2.3.2</maven-compiler-plugin-version>
    <java-version>1.6</java-version>
    <maven-eclipse-plugin-version>2.8</maven-eclipse-plugin-version>
    <org.codehaus.jackson-version>1.9.7</org.codehaus.jackson-version>
</properties>

<repositories>         
    <repository>
        <id>org.springframework.maven.snapshot</id>
        <name>Spring Maven Snapshot Repository</name>
        <url>http://maven.springframework.org/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>         <!-- For developing against latest Spring milestones -->
    <repository>
        <id>org.springframework.maven.milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://maven.springframework.org/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

</repositories>
<build>
    <finalName>${project.artifactId}</finalName>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>${android-maven-plugin-version}</version>
            <configuration>
                <sdk>
                    <platform>${android-platform}</platform>
                    <path>/Users/rav/Documents/Android/android-sdk-macosx</path>
                </sdk>
                <emulator>
                    <avd>Android4.1</avd>
                </emulator>
                <deleteConflictingFiles>true</deleteConflictingFiles>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin-version}</version>
            <configuration>
                <source>${java-version}</source>
                <target>${java-version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>${maven-eclipse-plugin-version}</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                                    <artifactId>android-maven-plugin</artifactId>
                                    <versionRange>[3.1.1,)</versionRange>
                                    <goals>
                                        <goal>proguard</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.android</groupId>
        <artifactId>spring-android-rest-template</artifactId>
        <version>1.0.0.RELEASE</version>
    </dependency> 
    <dependency>
        <groupId>com.j256.ormlite</groupId>
        <artifactId>ormlite-android</artifactId>
        <version>4.9</version>
    </dependency>
     <dependency>
            <groupId>com.j256.ormlite</groupId>
            <artifactId>ormlite-android</artifactId>
            <version>4.9</version>
            <exclusions>
                <exclusion>
                    <groupId>com.j256.ormlite</groupId>
                    <artifactId>ormlite-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    <dependency>
        <groupId>org.roboguice</groupId>
        <artifactId>roboguice</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>jsr305</artifactId>
        <version>1.3.9</version>
     </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>r6</version>
    </dependency>
    <dependency>
        <groupId>jgilfelt.android-viewbadger</groupId>
        <artifactId>android-viewbadger</artifactId>
        <version>1</version>
    </dependency>
    <dependency>
        <!-- Using Jackson for JSON marshaling -->
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${org.codehaus.jackson-version}</version>
    </dependency>
</dependencies>

**EDIT
Well, first i was using version 4.9 of ORMLite with isn’t really official, and didn’t have the methods I wanted to use. After I changed my pom.xml to use android-4.42 and core-4.42 Maven didn’t let me compile the program, giving the Dalvik error (“Conversion to Dalvik format failed with error 1”) despite of my attempts to solve this problem, I couldn’t.

I created a new project in a new workspace without Maven and added the libs manually, now everything works fine. It seems to be a Maven problem.
I hope it helps someone.**

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:32:24+00:00Added an answer on June 15, 2026 at 11:32 pm

    when I try to do: “iterator.getRawResults();” well, the iterator class don’t recognize the getRawResults method.

    I’m confused by this. CloseableIterator has supported this method since version 4.30. You may need to upgrade to a more recent version.

    AndroidDatabaseResults results =
        (AndroidDatabaseResults)iterator.getRawResults();
    Cursor cursor = results.getRawCursor();
    

    You say that this is a failed attempt but the code is correct. Please let me know what exceptions you are getting or what problems you are seeing and I can address them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve data using query from the sqlite database that was
I'm trying to retrieve a single entity from a Linq2Sql query, but I'm having
I am trying to retrieve the date only from my table and store it
I'm trying to make a query that must to retrieve some data from my
I am trying retrieve user name from the code through graph api, the below
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
Hi I am trying to retrieve values from database. I have a row which
I am trying to retrieve a column from another related table, and display that
I'm trying to retrieve product information from magento by calling its web service using
I'm trying to retrieve the attribute value from an xsl:param and use it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.