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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:16:05+00:00 2026-06-08T18:16:05+00:00

The entries are getting submitted successfully but when pressing the view button, the application

  • 0

The entries are getting submitted successfully but when pressing the “view” button, the application crashes and Logcat output is:

D/Error(2808): android.database.sqlite.SQLiteException: no such column: names: , while compiling: SELECT id, names, items, quantity, price FROM orderDetails

How do I resolve this?

public class DatabaseHandler extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "orders";
private static final String TABLE_ORDERS = "orderDetails";

// Now, column names

private static final String KEY_ID = "id";
private static final String KEY_NAME = "names";
private static final String KEY_ITEM = "items";
private static final String KEY_QUANTITY = "quantity";
private static final String KEY_PRICE = "price";

private DatabaseHandler handler;
private final Context myContext;
private SQLiteDatabase myDatabase;

public DatabaseHandler(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    myContext = context;
}

@Override
public void onCreate(SQLiteDatabase db) {

    String CREATE_TABLE = "CREATE TABLE " + TABLE_ORDERS + "(" + KEY_ID
            + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_ITEM + " BLOB, "
            + KEY_QUANTITY + " REAL, " + KEY_PRICE + " REAL);";
    db.execSQL(CREATE_TABLE);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_ORDERS);
    onCreate(db);
}

public void addEntry(String name, String item, float quantity, float price) {
    try {
        handler = new DatabaseHandler(myContext);
        myDatabase = handler.getWritableDatabase();

        ContentValues cv = new ContentValues();
        cv.put(KEY_NAME, name);
        cv.put(KEY_ITEM, item);
        cv.put(KEY_QUANTITY, quantity);
        cv.put(KEY_PRICE, price);

        myDatabase.insert(TABLE_ORDERS, null, cv);
        handler.close();

        // delete this toast
        Toast.makeText(myContext, "It worked", Toast.LENGTH_SHORT).show();

    } catch (Exception e) {
        // TODO Auto-generated catch block

        Toast.makeText(myContext, "It failed", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
        Log.d("Error", e.toString());
    }

}

public String getEntries() {

    try {
        handler = new DatabaseHandler(myContext);
        myDatabase = handler.getReadableDatabase();
        String[] columns = new String[] { KEY_ID, KEY_NAME, KEY_ITEM,
                KEY_QUANTITY, KEY_PRICE };

        Cursor c = myDatabase.query(TABLE_ORDERS, columns, null, null, null,
                null, null);
        String result = "";

        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
            result = result + c.getString(0) + " |" + c.getString(1) + " |"
                    + c.getString(2) + " |" + c.getString(3) + " |"
                    + c.getString(4) + "\n";
        }
        handler.close();
        return result;
    } catch (Exception e) {
        Log.d("Error", e.toString());
        e.printStackTrace();
        return null;

    }
}

}

  • 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-08T18:16:07+00:00Added an answer on June 8, 2026 at 6:16 pm

    SOLUTION

    [1] First of all delete the created database from your AVD or Real Device, because the table already created there has not column KEY_NAME(“names”)

    [2] Then next time when will you run app the table will created with following code in table::

    String CREATE_TABLE = "CREATE TABLE " + TABLE_ORDERS + "(" + KEY_ID
                + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_ITEM + " BLOB, "
                + KEY_NAME + " TEXT, "  //  ADD THIS  COLUMN
                + KEY_QUANTITY + " REAL, " + KEY_PRICE + " REAL);";
        db.execSQL(CREATE_TABLE);
    

    You have forgotten to put KEY_NAME in creation query of table see following is your code:

    String CREATE_TABLE = "CREATE TABLE " + TABLE_ORDERS + "(" + KEY_ID
                + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_ITEM + " BLOB, "
                + KEY_QUANTITY + " REAL, " + KEY_PRICE + " REAL);";
        db.execSQL(CREATE_TABLE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an error when using my application that used tableviews, the error
I keep getting this log entries on ubuntu 10.04 lts: # vim /var/log/apache2/error.log [Sun
Validations are working but form is not getting submitted and data is not inserted:
I am getting Access violation error from the debugger, but I really have no
I keep getting duplicate entries in my database because of impatient users clicking the
I have the following code (only sections of it) for getting the entries in
I am having difficulty getting rid of duplicate entries which are showing up in
why isn't my while loop getting the mysql database entries and presenting them like
Hi I am getting a fault in a php application leading sometimes to an
I just enabled the slow-log (+not using indexes) and I'm getting hundreds of entries

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.