SQLite在CREATE附近创建表错误

时间:2018-07-10 08:29:18

标签: sqlite create-table

当我在sqlite中创建表时,查询的创建部分发生错误。

private static final String DB_Table="CREATE TABLE IF NOT EXISTS "+
        DBHelper.TABLENAME +
        "(" +
        DB_id+" INTEGER PRIMARY KEY AUTOINCREMENT,"+
        DB_REGID+" TEXT,"+DB_Path+" TEXT);";

我不知道问题出在哪儿。我提出的查询是正确的(我认为)。 日志显示

07-10 04:21:22.655 5339-5339/com.example.steffi.medpharm E/SQLiteLog: (1) near "CREATE": syntax error
07-10 04:21:22.656 5339-5339/com.example.steffi.medpharm E/SQLiteDatabase: Error inserting id_reg=0 image_path=/storage/emulated/0/Download/blue.jpg
android.database.sqlite.SQLiteException: near "CREATE": syntax error (code 1): , while compiling: INSERT INTO CREATE TABLE IF NOT EXISTS navigation_table(_id INTEGER PRIMARY KEY AUTOINCREMENT,id_reg TEXT,image_path TEXT);(id_reg,image_path) VALUES (?,?)
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
    at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1470)
    at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1343)
    at com.example.steffi.medpharm.DBHelper.putPath(DBHelper.java:77)
    at com.example.steffi.medpharm.NavigationMain.onActivityResult(NavigationMain.java:201)
    at android.app.Activity.dispatchActivityResult(Activity.java:6917)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)
    at android.app.ActivityThread.-wrap20(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

0 个答案:

没有答案