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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:41:32+00:00 2026-05-27T06:41:32+00:00

I have an SQLiteDatabase helper, which returns a cursor with just the name column

  • 0

I have an SQLiteDatabase helper, which returns a cursor with just the name column from a database:

public Cursor getNames() {
    Cursor cursor = db.query(TABLE_NAME, new String[] {NAME}, null, null, null, null, null);
    return cursor;
}

I am trying to bind this cursor to a simple ListView contained in the Layout:

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>

The java:

 Cursor cursor = db.getNames();
    startManagingCursor(cursor);

    ListAdapter adapter = new SimpleCursorAdapter (
            this,
            android.R.layout.simple_list_item_1,
            cursor,
            new String[] {constants.NAME},
            new int[] {android.R.id.text1}
            );

    setListAdapter(adapter);

I’ve followed every tutorial I can find but the app still stops unexpectedly. Please tell me what I’m doing wrong!

Here’s the LOGCAT trace, hope thats what you needed:

12-03 17:18:41.557: E/AndroidRuntime(30413): FATAL EXCEPTION: main
12-03 17:18:41.557: E/AndroidRuntime(30413): java.lang.RuntimeException: Unable to start activity ComponentInfo{george.frost.YourCarbDatabase/com.android.CarbCount.Search}: java.lang.IllegalArgumentException: column '_id' does not exist
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.os.Looper.loop(Looper.java:130)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.ActivityThread.main(ActivityThread.java:3701)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at java.lang.reflect.Method.invokeNative(Native Method)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at java.lang.reflect.Method.invoke(Method.java:507)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at dalvik.system.NativeStart.main(Native Method)
12-03 17:18:41.557: E/AndroidRuntime(30413): Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.widget.CursorAdapter.init(CursorAdapter.java:111)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.widget.CursorAdapter.<init>(CursorAdapter.java:90)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.widget.ResourceCursorAdapter.<init>(ResourceCursorAdapter.java:47)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:84)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at com.android.CarbCount.Search.onCreate(Search.java:42)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-03 17:18:41.557: E/AndroidRuntime(30413):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
12-03 17:18:41.557: E/AndroidRuntime(30413):    ... 11 more
  • 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-27T06:41:33+00:00Added an answer on May 27, 2026 at 6:41 am

    The startManagingCursor()-method is deprecated. You should use the Loader API instead. If you’re targeting devices with an API-Level lower then 11, you’ll want to use the compatibility library.

    Since it seams that you simply want to load some data from your SQLiteDatabase, you don’t need to create a ContentProvider but can extend Loader. An example and more information on this can be found here: CursorLoader usage without ContentProvider

    Also, if your Activity only shows a ListView, you might want to switch to a ListActivity, since it makes binding data and getting ID’s (for example) easier for you.


    Since you posted your LogCat:

    The problem is, that the SimpleCursorAdapter-class needs a column named _id to get an ID on every row of data from your Database. More information on that problem can be found here: Android column '_id' does not exist?

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

Sidebar

Related Questions

I have a listview which loads its data from sqlite database. Each row in
I am using the SQLite database and have the following persistent class (simplified): public
I have a DataTable which I want to save to a SQLite Database Table.
I have a component that i want to store to an SQLite database. public
I have a complex network of objects being spawned from a sqlite database using
I have implemented a custom SQLite database helper. I have a table containing sms
I have a class: public class DbAdapter { private DbHelper dbHelper; private SQLiteDatabase db;
I have an sqlite database that has a blob column with blob data. I
I have a database that I have created with the following handler: public class
I have built a database helper class with an open() method and extended sqlite

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.