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 8527685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:37:32+00:00 2026-06-11T08:37:32+00:00

I am modifying my Android app to work with ORMLite, and it currently uses

  • 0

I am modifying my Android app to work with ORMLite, and it currently uses a number of CursorAdapters, which I quite want to keep in an attempt to minimise coding.

I’m not 100% sure but t appears that when ORMLite creates an id field in the db, it always uses id, whereas CursorAdapter needs _id.

It is possible to get round this using a query like the following:

select id as _id ......

but the Dao.queryRaw() method returns a list, not a Cursor, so the way I have done it is to open another SQLiteOpenHelper database connection and use rawQuery().

This works, but are there any better ways of doing it at all? It seems overkill to have two separate database connections, and perhaps storing up trouble later.

  • 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-11T08:37:34+00:00Added an answer on June 11, 2026 at 8:37 am

    Your comments indicate that you’ve already answered you problem. You can certainly create a column named “_id” using ORMLite:

    @DatabaseField(generatedId = true)
    private int _id;
    

    or

    @DatabaseField(generatedId = true, columnName = "_id")
    private int id;
    

    If you are working with Cursors then you may want to take a look at the last() and moveAbsolute(...) methods on the DatabaseResults class. Also, the AndroidDatabaseResults (which you can cast to) also has a getRawCursor() method which returns the underlying Cursor object and has additional getCount() and getPosition() methods.

    Here are some more information about ORMLite and Cursors:

    Android Cursor with ORMLite to use in CursorAdapter

    You can get access to the Cursor using something like the following:

    // build your query
    QueryBuilder<Foo, String> qb = fooDao.queryBuilder();
    qb.where()...;
    // when you are done, prepare your query and build an iterator
    CloseableIterator<Foo> iterator = dao.iterator(qb.prepare());
    try {
       // get the raw results which can be cast under Android
       AndroidDatabaseResults results =
           (AndroidDatabaseResults)iterator.getRawResults();
       Cursor cursor = results.getRawCursor();
       ...
    } finally {
       iterator.closeQuietly();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm modifying an Android app that utilizes a webapp via a webview. Currently the
I start my android app writing with modifying some example codes from the internet.
I am modifying CyanogenMod (CM 7) Source code, i want to include Cyanogen/packages/apps/phone/src/com/android/phone/CallNotifier.java in
(Modifying the question)I have a windows form app in C# which calls into some
I'm working on a relatively simple Android app. I want it to have an
I'm trying to create a simple Android app which saves a text from an
So I've been modifying the notepad tutorial code: http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html . Basically what I want
I am modifying an existing WinForms app which is setup with a custom TraceListener
I am modifying the android OS slightly and wish to access a specific app's
I'm modifying an existing application in C++ that uses GLUT (so I can't get

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.