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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:01:08+00:00 2026-06-07T03:01:08+00:00

I am working on an application which stores some data in sqlite, while creating

  • 0

I am working on an application which stores some data in sqlite, while creating table android throws an exception:

Failure 1 : Syntax error  near table1. on Ox12d510

I am unable to identify what I am doing wrong. Source code:

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MySQLiteHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "bedekar12.db";  
    public static final int DATABASE_VERSION = 1;

    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_1 = "column1";
    public static final String PRODUCT_NAME = "product_name";
    public static final String PRODUCT_CATEGORY = "product_category";
    public static final String ORDER_ID = "order_id";
    public static final String ORDER_DATE = "order_date";
    public static final String CUSTOMER_ID = "customer_id";
    public static final String TOTAL = "total";
    public static final String SALESMAN_ID = "salesman_id";
    public static final String ORDER_STATUS = "order_status";
    public static final String PRODUCT_ID = "product_id";
    public static final String PACKAGE_ID = "package_id";
    public static final String QUANTITY = "quantity";
    public static final String PACKGAGE = "package";
    public static final String WEIGHT = "weight";
    public static final String PRICE = "price";
    public static final String CUSTOMER_NO = "customer_no";
    public static final String CUSTOMER_NAME = "customer_name";
    public static final String CUSTOMER_ADD = "customer_add";
    public static final String CUSTOMER_CITY = "customer_city";
    public static final String CUSTOMER_REGION = "customer_region";
    public static final String CUSTOMER_POSTAL = "customer_postal";
    public static final String CONTACT = "contact";
    public static final String CUSTOMER_TITLE = "customer_title";
    public static final String CUSTOMER_PHONE = "customer_phone";
    public static final String CUSTOMER_EMAIL = "customer_email";
    public static final String LAT = "lat";
    public static final String LNG = "lng";
    public static final String EVENTS_DATE = "events_date";
    public static final String EVENTS_MSG = "events_msg"; 

    // 1. News Table
    public static final String NEWS_TABLE = "news_table";
    public static final String NEWS_CREATE = "create table " + NEWS_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key , "
                                        + COLUMN_1 + " text not null ); ";

    // 2. product table
    public static final String PRODUCT_TABLE = "product_table";
    public static final String PRODUCT_CREATE = "create table " + PRODUCT_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key , "
                                        + PRODUCT_ID + " text not null, "
                                        + PRODUCT_NAME + " text not null, "
                                        + PRODUCT_CATEGORY + " text not null ); "; 
    // 3. order table
    public static final String ORDER_TABLE = "order_table";
    public static final String ORDER_CREATE = "create table " + ORDER_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key, "
                                        + ORDER_ID + " text not null, "
                                        + ORDER_DATE + " text not null, "
                                        + CUSTOMER_ID + " text not null, "
                                        + TOTAL + " text not null, "
                                        + SALESMAN_ID + " text not null, "
                                        + ORDER_STATUS + " text not null ); ";

    // 4. return order table
    public static final String RETURN_ORDER_TABLE = "return_order_table";
    public static final String RETURN_ORDER_CREATE = "create table " + ORDER_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key, "
                                        + ORDER_ID + " text not null, "
                                        + ORDER_DATE + " text not null, "
                                        + CUSTOMER_ID + " text not null, "
                                        + TOTAL + " text not null, "
                                        + SALESMAN_ID + " text not null, "
                                        + ORDER_STATUS + " text not null ); ";

    // 5. OrderDetails Table
    public static final String ORDER_DETAILS_TABLE = "details_table";
    public static final String ORDER_DETAILS_CREATE = "create table " + ORDER_DETAILS_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key , "
                                        + ORDER_ID + " text not null, "
                                        + PRODUCT_ID + " text not null, "
                                        + PACKAGE_ID + " text not null, "
                                        + QUANTITY + " text not null, "
                                        + PRICE + " text );";

    // 6. Return OrderDetails Table
    public static final String RETURN_ORDER_DETAILS_TABLE = "return_details_table";
    public static final String RETURN_ORDER_DETAILS_CREATE = "create table " + ORDER_DETAILS_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key, "
                                        + ORDER_ID + " text not null, "
                                        + PRODUCT_ID + " text not null, "
                                        + PACKAGE_ID + " text not null, "
                                        + QUANTITY + " text not null, "
                                        + PRICE + " text );";

    // 7. Package table
    public static final String PACKAGING_TABLE = "packaging_table";
    public static final String PACKAGING_CREATE = "create table " + PACKAGING_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key, " 
                                        + PRODUCT_ID + " text not null, "
                                        + PACKAGE_ID + " text not null, "
                                        + PACKGAGE + " text not null, "
                                        + WEIGHT + " text not null, "
                                        + QUANTITY + " text not null, "
                                        + PRICE + " text not null );";

    // 8. Customer table
    public static final String CUSTOMER_TABLE = "customer_table";
    public static final String CUSTOMER_CREATE = "create table " + CUSTOMER_TABLE + " ( "
                                        + COLUMN_ID + " integer primary key, "
                                        + CUSTOMER_NAME + " text not null, "
                                        + CUSTOMER_ADD + " text not null, "
                                        + CUSTOMER_CITY + " text not null, "
                                        + CUSTOMER_REGION + " text not null, "
                                        + CUSTOMER_POSTAL + " text not null, "
                                        + CONTACT + " text not null, "
                                        + CUSTOMER_TITLE + " text not null, "
                                        + CUSTOMER_PHONE + " text not null, "
                                        + CUSTOMER_EMAIL + " text not null, "
                                        + LAT + " text not null, "
                                        + LNG + " text not null ); ";

    // 9. Event table;
        public static final String EVENTS_TABLE = "events_table";
        public static final String EVENTS_CREATE = "create table " + EVENTS_TABLE + " ( "
                                            + COLUMN_ID + " integer primary key, "
                                            + EVENTS_DATE + " text not null, "
                                            + EVENTS_MSG + " text not null ); ";



    public MySQLiteHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(NEWS_TABLE);
        db.execSQL(PRODUCT_TABLE);
        db.execSQL(ORDER_TABLE);
        db.execSQL(RETURN_ORDER_TABLE);
        db.execSQL(ORDER_DETAILS_TABLE);
        db.execSQL(RETURN_ORDER_DETAILS_TABLE);
        db.execSQL(PACKAGING_TABLE);
        db.execSQL(CUSTOMER_TABLE);
        db.execSQL(EVENTS_TABLE);
    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int version1, int version2) {
        db.execSQL("DROP TABLE IF EXISTS " + NEWS_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + PRODUCT_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + ORDER_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + RETURN_ORDER_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + ORDER_DETAILS_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + RETURN_ORDER_DETAILS_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + PACKAGING_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + CUSTOMER_TABLE);
        db.execSQL("DROP TABLE IF EXISTS " + EVENTS_TABLE);
        onCreate (db);
    }
}
  • 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-07T03:01:09+00:00Added an answer on June 7, 2026 at 3:01 am

    You are using the wrong string in your onCreate method… you are giving the table name only, not the string to create the tables.

    Change this:

    @Override 
    public void onCreate(SQLiteDatabase db) { 
        db.execSQL(NEWS_TABLE); 
        db.execSQL(PRODUCT_TABLE); 
        db.execSQL(ORDER_TABLE); 
        db.execSQL(RETURN_ORDER_TABLE); 
        db.execSQL(ORDER_DETAILS_TABLE); 
        db.execSQL(RETURN_ORDER_DETAILS_TABLE); 
        db.execSQL(PACKAGING_TABLE); 
        db.execSQL(CUSTOMER_TABLE); 
        db.execSQL(EVENTS_TABLE); 
    } 
    

    To this:

    @Override 
    public void onCreate(SQLiteDatabase db) { 
        db.execSQL(NEWS_CREATE); 
        db.execSQL(PRODUCT_CREATE); 
        db.execSQL(ORDER_CREATE); 
        db.execSQL(RETURN_ORDER_CREATE); 
        db.execSQL(ORDER_DETAILS_CREATE); 
        db.execSQL(RETURN_ORDER_DETAILS_CREATE); 
        db.execSQL(PACKAGING_CREATE); 
        db.execSQL(CUSTOMER_CREATE); 
        db.execSQL(EVENTS_CREATE); 
    } 
    

    As a side note, all of the primary keys should be called _id to facilitate use with android widgets. They all expect that to be the name of the primary key (it coded into the widgets so they can identify what data comes from what record when you do things like lists).

    One last pointer, it is also much easier to use the autoincrement feature for the ids so that you don’t have to manage the primary keys manually.

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

Sidebar

Related Questions

I'm working on an application which stores data in tables, similar to an RDBMS.
I am working on an application which accepts any uploaded CSV data, stores it
I am working on a content management application in which the data being stored
I'm working on an application which has data imported from a foreign (and wholly
I have an application in C# which I write some data to file. I
I'm working on an application which accesses data from an Oracle 11g database. I'm
I'm working on Android application which is taking content from internet using JSON, I
Am working on some application. However, i have finished two modules which invoke the
I've been working on a Play application (1.2.4) which will do some crunching on
I'm working on a WinForms application which also has some WPF elements. Until now

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.