gpt4 book ai didi

android - SQLITE建表错误

转载 作者:行者123 更新时间:2023-11-29 14:42:30 25 4
gpt4 key购买 nike

这是我用来创建表的代码

 private static final String DATABASE_CREATE =
"create table notes (_id integer primary key autoincrement,"
+ "title text not null, body text not null,email text not null,group text);";

logcat 显示:

11-23 08:22:32.992: ERROR/AndroidRuntime(1008): FATAL EXCEPTION: main
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android/com.android.managecontact}: android.database.sqlite.SQLiteException: near "group": syntax error: , while compiling: SELECT _id, title, body, email, group FROM notes ORDER BY title
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.os.Looper.loop(Looper.java:123)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at java.lang.reflect.Method.invoke(Method.java:521)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at dalvik.system.NativeStart.main(Native Method)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): Caused by: android.database.sqlite.SQLiteException: near "group": syntax error: , while compiling: SELECT _id, title, body, email, group FROM notes ORDER BY title
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at com.android.database.fetchAllNotes(database.java:156)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at com.android.managecontact.fillData(managecontact.java:118)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at com.android.managecontact.onCreate(managecontact.java:89)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-23 08:22:32.992: ERROR/AndroidRuntime(1008): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

最佳答案

GROUP 是保留关键字。使用不同的名称。

关于android - SQLITE建表错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4251905/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com