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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:36:55+00:00 2026-06-07T20:36:55+00:00

Don’t immediately flag me for a duplicate question. My issue is different because I

  • 0

Don’t immediately flag me for a duplicate question. My issue is different because I have a correctly formatted SQL query.

public static final String TABLE_NAME = "log";
public static final String COLUMN_ID = "_id";
public static final String LOG_TEXT = "logtext";
private static final String TABLE_CREATE = "CREATE TABLE " + TABLE_NAME + " (" +
        COLUMN_ID + " integer primary key autoincrement, " +
        LOG_TEXT + " TEXT not null);";

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(TABLE_CREATE);

}

and I query here

String[] columns = {LOG_TEXT,COLUMN_ID};
    Cursor cursor = helper.getReadableDatabase().query(TABLE_NAME, columns, null, null, null, null, COLUMN_ID + " desc");

and I catch this the exception generated containing the sql query.

catch(Exception e){
Log.D("sql Exception",e.getMessage());}

and it returns

no such column: _id: , while compiling: SELECT logtext, _id FROM log ORDER BY _id desc

I’m familar with Oracle SQL and relational databases in general. Is it my ORDER BY clause? I was certain you can ALWAYS use order by. It doesn’t have the same behavior as GROUP BY.

Any ideas on why the exception?
Incase anyone wants to see i’m updating with my ArrayAdaptor statements. I’m using the cursor in a listview

String[] data = query();


    adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, android.R.id.text1, data);
    listView.setAdapter(adapter);}
  • 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-07T20:36:56+00:00Added an answer on June 7, 2026 at 8:36 pm

    Rewrite

    Whenever you change the schema in TABLE_CREATE you must inform you app of these changes, they will not happen automatically when you change TABLE_CREATE. The easiest way to do this is to increment your database_version in your extended SQLiteOpenHelper class. You discovered you can also uninstall / reinstall the app, for the same results. If you are savvy with SQL you could ALTER the table. But whatever the method you must make sure that you app makes the schema changes before trying to access the new columns…

    Also for SQLite:

    _id integer primary key
    

    is synonymous with:

    _id integer primary key autoincrement not null
    

    And queries use descending as the default order, so ORDER BY _id is the same as ORDER BY _id DESC.

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

Sidebar

Related Questions

Don't think my virtualhost is working correctly. This is what I have inside of
Don't you hate it when you have class Foobar { public: Something& getSomething(int index)
Don't ask me how but I'm in a situation where I have DCPs published
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't know how to google for such, but is there a way to query
Don't know if I worded the question right, but basically what I want to
Don't know if this has been asked before, so point me to another question
Don't they both have to convert to machine code at some point to execute
I don't know if this question is trivial or not. But after a couple
Don't overthink this - there's a very commonly used term and I ... have

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.