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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:09:56+00:00 2026-06-18T03:09:56+00:00

I have been a naughty boy and I’ve copied a method from official Notepad

  • 0

I have been a naughty boy and I’ve copied a method from official Notepad application from android developer site, this is my class :

package com.example.prva;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;


public class ListView extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listview);
        fillData();
        }

    private void fillData() {
        // Get all of the notes from the database and create the item list
        Cursor c = DatabaseManager.getAllData();
        startManagingCursor(c);

        String[] from = new String[] { DatabaseManager.TABLE_COLUMN_ONE };
        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);
    }
    }

When I try to run this ListActivity I get this error :

01-31 02:39:14.259: E/AndroidRuntime(1845): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.prva/com.example.prva.ListView}: java.lang.IllegalArgumentException: column '_id' does not exist

Now I understand this because its true, I do not have the _id column in my database (the notepad application database has it and used it but I have my own database), I just don’t understand where is that column mentioned in my ListActivity class? Where is it being called from so it gives the error?

  • 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-18T03:09:57+00:00Added an answer on June 18, 2026 at 3:09 am

    See the documentation for CursorAdapter:

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

    In your code, you use the SimpleCursorAdapter, which is a derived class, so it appears this statement applies.

    Cursors are like iterators or pointers, they contain nothing but a mechanism for transversing the data, they contain no columns themselves.

    From another documentation, you can understand the statement above better:

    Handling content URI IDs

    By convention, providers offer access to a single row in a table by
    accepting a content URI with an ID value for the row at the end of the
    URI. Also by convention, providers match the ID value to the table’s
    _ID column, and perform the requested access against the row that matches.

    This convention facilitates a common design pattern for apps accessing
    a provider. The app does a query against the provider and displays the
    resulting Cursor in a ListView using a CursorAdapter. The definition
    of CursorAdapter requires one of the columns in the Cursor to be _ID.

    Several ways for you to fix the problem:

    1. Add a column “_id” in your table.

    2. Using alias to get the curosr. For example:

      SELECT someid as _id, name, number FROM TABLE1;

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

Sidebar

Related Questions

have been away from Android for more than a year, trying to pick up
I have been using the method to import excel data to my WPF application
Have been working on this question for a couple hours and have come close
I have been working with SQL Server as a Developer a while. One thing
Have been trying to figure this problem out for a while now and was
have been able to output images from BLOB, however I am now wanting to
I have been reading here https://developer.mozilla.org/en-US/docs/JavaScript/Memory_Management#Allocation_via_function_calls and these lines confused me a bit: var
Have been fighting this for two days and am very frustrated but feel like
Have been looking around for a solution to this and have found some help
Have been stuck on this (beginner) issue for a while so am now asking

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.