-3
 @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" +
                            KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                            KEY_NAME + " TEXT NOT NULL, " +
                            KEY_SKILL + " TEXT NOT NULL" +
                            KEY_COUNTY + "TEXT NOT NULL);"
            );

            db.execSQL(" CREATE TABLE " + DATABASE_BANK + " ("+                     //SQL CREATE statement for Bank table
                    KEY_ROWID + " INTEGER NOT NULL PRIMARY KEY);");
        }

In an on create method I created this table however when I run the app it tells me that there is something wrong with key county. Below I will post the logcat. It says "no such column: business_county", the only place I have this referenced is here

public static final String KEY_ROWID = "_id";
    public static final String KEY_NAME = "persons_name";
    public static final String KEY_SKILL = "persons_skill";
    public static final String KEY_COUNTY = "business_county";

however I thought that it didn't matter if you put peanut butter for example in the brackets, it was whatever you wanted.

Logcat:

11-29 23:22:41.343 23491-23491/com.example.tl.firstdb W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
11-29 23:22:41.344 23491-23491/com.example.tl.firstdb W/ViewRootImpl: Dropping event due to root view being removed: MotionEvent { action=ACTION_MOVE, actionButton=0, id[0]=0, x[0]=218.31485, y[0]=200.40204, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=185996190, downTime=185996177, deviceId=6, source=0x1002 }
11-29 23:22:41.344 23491-23491/com.example.tl.firstdb W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
11-29 23:22:42.101 23491-23491/com.example.tl.firstdb I/System.out: The Context from skillslevel class com.example.tl.firstdb.SQLView
11-29 23:22:42.105 23491-23491/com.example.tl.firstdb E/SQLiteLog: (1) no such column: business_county
11-29 23:22:42.106 23491-23491/com.example.tl.firstdb D/AndroidRuntime: Shutting down VM
11-29 23:22:42.107 23491-23491/com.example.tl.firstdb E/AndroidRuntime: FATAL EXCEPTION: main
                                                                        Process: com.example.tl.firstdb, PID: 23491
                                                                        java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.example.tl.firstdb/com.example.tl.firstdb.SQLView}: android.database.sqlite.SQLiteException: no such column: business_county (code 1): , while compiling: SELECT _id, persons_name, persons_skill, business_county FROM peopleTable
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
                                                                            at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:148)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5443)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
                                                                         Caused by: android.database.sqlite.SQLiteException: no such column: business_county (code 1): , while compiling: SELECT _id, persons_name, persons_skill, business_county FROM peopleTable
                                                                            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                                            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
                                                                            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
                                                                            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                                            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                                                                            at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
                                                                            at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
                                                                            at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
                                                                            at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)
                                                                            at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)
                                                                            at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1202)
                                                                            at com.example.tl.firstdb.SkillsLevel.getData(SkillsLevel.java:107)
                                                                            at com.example.tl.firstdb.SQLView.onCreate(SQLView.java:37)
                                                                            at android.app.Activity.performCreate(Activity.java:6245)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
                                                                            at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:148) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5443) 
John_K
  • 114
  • 1
  • 2
  • 10

2 Answers2

1

You are missing a comma in your create table statement, between TEXT NOT NULL and the KEY_COUNTY column name. After you fix this typo, you will need to remove the database by either clearing the app data in Settings > Apps, or uninstalling and reinstalling.

Karakuri
  • 38,365
  • 12
  • 84
  • 104
0

You are missed comma after keyskill and you need to put the space between column name and the column type ..Like this .. I mentioned here as &nbsp .. KEY_COUNTY + "&nbspTEXT NOT NULL);"

Noorul
  • 3,386
  • 3
  • 32
  • 54