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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:14:36+00:00 2026-06-02T05:14:36+00:00

On a single table I do it like this: public static String[] FROM_Benzinarii_onList =

  • 0

On a single table I do it like this:

public static String[] FROM_Benzinarii_onList = {DBConstants.Denumire_Benzinarie, DBConstants.Adresa, DBConstants.Distance, _ID};

public Cursor getStations_List(){
        db = helper.getReadableDatabase();
        return db.query(DBConstants.TABELA_BENZINARII, FROM_Benzinarii_onList, null, null, null, null, null);

Then construct the adapter:

int[] values = {R.id.tv_benzinarie,R.id.tv_adresa,R.id.tv_dist}
Cursor cursor = getStations_List();
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(getBaseContext(), R.layout.item_list, cursor,FROM_Benzinarii_onList, values);
     setListAdapter(adapter);

But now I need an extra colum, with price, from another table, and I am unable to obtain a cursor. I have tried the code below, and many others.

public static String[] FROM_Benzinarii_onList = {DBConstants.Denumire_Benzinarie, DBConstants.Adresa, DBConstants.Distance, DBConstants.Pret, _ID};

public Cursor getStations_List(){
        db = helper.getReadableDatabase();
        String sql = " select " + DBConstants.TABELA_BENZINARII + "." + DBConstants.Denumire_Benzinarie + "," + DBConstants.TABELA_BENZINARII + "." + DBConstants.Adresa 
                + "," + DBConstants.TABELA_BENZINARII + "." + DBConstants.Distance + "," + DBConstants.TABELA_PRETURI + "." + DBConstants.Pret 
                + " from " + DBConstants.TABELA_PRETURI + "," + DBConstants.TABELA_BENZINARII
                + " where " + DBConstants.TABELA_BENZINARII + "." + DBConstants.ID_Benzinarie + " = " + DBConstants.TABELA_PRETURI + "." + DBConstants.ID_Benz;
        return db.rawQuery(sql, null);
    }

Then construct the SimpleAdapter in the same way (I don’t know if it is correct !?)

int[] values = {R.id.tv_benzinarie,R.id.tv_adresa,R.id.tv_dist,R.id.tv_pret};

Cursor cursor = getStations_List();

SimpleCursorAdapter adapter = new SimpleCursorAdapter(getBaseContext(), R.layout.item_list, cursor,FROM_Benzinarii_onList, values);
        setListAdapter(adapter);

I get:

 Caused by: java.lang.IllegalArgumentException: column '_id' does not exist

I don’t know if my new cursor has anything to do with FROM_Benzinarii_onList but I couldn’t use db.query here
Please help!

  • 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-02T05:14:38+00:00Added an answer on June 2, 2026 at 5:14 am

    See my answer Android column _id does not exist problem

    Try using an alias such as select oid as _id... as in my answer.

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

Sidebar

Related Questions

Let's say you have a database with a single table like... --------------------------------------------- | Name
I would like to update 3 rows of a single table, with different values
i have a table like this one: id | name | score mapped to
Imagine I have a service that looks like this: public interface MyAccountService { boolean
I have an object in C# like this: private ClassWidget { public int ID;
Im trying set the single table inheritance model type in a form. So i
I am using Single Table Inheritance for managing different types of projects. Models: class
I'm using Doctrine 2 and single table inheritance, my topmost entity hierarchy is: JS_File
I have a huge access mdb file which contains a single table with 20-30
Im trying to return a SimpleQuery list that queries a single table and uses

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.