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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:50:49+00:00 2026-05-16T23:50:49+00:00

is it possible to populate a listview based on a row Id from a

  • 0

is it possible to populate a listview based on a row Id from a custom cursor adapter. I keep getting an error “illegalArguementException column: _id does not exist”. but the database has it and is already being used correctly. I don’t know what to do, because I would need to populate different listviews from the same database and i don’t want to have to create multiple database which will still have the same column names. Any ideas will be greatly appreciated. thanks

HERE is the database code is being cold:

public Cursor retrieveItemRow(long Id){
        open();
String[] Columns = new String[] {TITLE,DATE, TIME};
Cursor row = db.query(true,DATABASE_TABLE, Columns, KEY_ID +"=" +Id, null, null, null, null,null);
    if(row != null){
    row.moveToNext();
    return row;
    }
    return row;
      }

Here is a method i am trying to call it in:

 public void fillRowData(long Id) {

Cursor cursor = adapter.retrieveRow(id);
startManagingCursor(cursor);
String[] from = new String[]{DBAdapter.TITLE, DBAdapter.DATE, DBAdapter.TIME};
int[] to = new int[]{R.id.Name, R.id.Date, R.id.Time};

customCursor items = new customCursor(this, R.layout.viewlist, cursor, from, to);
setListAdapter(items);          

}
  • 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-05-16T23:50:49+00:00Added an answer on May 16, 2026 at 11:50 pm

    Make sure you include _id in the SELECT statement represented by the Cursor you pass into your adapter. For example, if I were using the SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to), my Cursor c would originate with something like “SELECT _id, name FROM users;”.

    From the Notepad Tutorial:

    private void fillData() {
         // Get all of the notes from the database and create the item list
         Cursor c = mDbHelper.fetchAllNotes();
         startManagingCursor(c);
    
         String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
         int[] to = new int[] { R.id.text1 };
    
         // Now create an array adapter and set it to display using our row
         SimpleCursorAdapter notes =
              new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
         setListAdapter(notes);
    }
    

    The tutorial defines a method in the database helper class that returns all of the Note objects. Essentially they’re using SQLiteDatabase‘s query method that returns a Cursor object. The query’s select string is where you should include the _id column.

    So in your case, you need to add KEY_ID to your Columns String array variable, because those are the columns that are included in your select statement (db.query()). This is also hinted at in the CursorAdapter documentation:

    The Cursor must include a column named
    “_id” or this class will not work.

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

Sidebar

Related Questions

Is it possible? Developers can use SMS URLs to populate the phone number, but
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: What Ruby IDE do you prefer? I've generally been doing stuff on
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the

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.